使用Mediaplayer播放本地音频,在第二次调用mediaplayer.setDataSource()时报错如下:

Caused by: java.lang.IllegalStateException
at android.media.MediaPlayer._setDataSource(Native Method)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:)
...

那么,使用reset()可解决mediaplayer引起的吃饭不香IllegalStateException问题

在mMediaPlayer.setDataSource(path);之前加一句mMediaPlayer.reset();即可

Caused by:java.lang.IllegalStateException at android.media.MediaPlayer._setDataSource(Native Method)的更多相关文章

  1. Caused by java.lang.IllegalStateException Not allowed to start service Intent { cmp=com.x.x.x/.x.x.xService }: app is in background uid UidRecord(一)

    Caused by java.lang.IllegalStateException Not allowed to start service Intent { cmp=com.x.x.x/.x.x.x ...

  2. Caused by: java.lang.IllegalStateException: Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError

    SLF4J: Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackO ...

  3. 【spring boot】【elasticsearch】spring boot整合elasticsearch,启动报错Caused by: java.lang.IllegalStateException: availableProcessors is already set to [8], rejecting [8

    spring boot整合elasticsearch, 启动报错: Caused by: java.lang.IllegalStateException: availableProcessors ], ...

  4. Caused by: java.lang.IllegalStateException: Method has too many Body parameters

    feign多参数问题1.1GET方式错误写法 @RequestMapping(value="/test", method=RequestMethod.GET) Model test ...

  5. Caused by: java.lang.IllegalStateException: Expected raw type form of org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$Match

    spring 4.0.2,mybatis 3.2.6,aspectjweaver 1.8.10 使用的时候,报错: Caused by: java.lang.IllegalStateException ...

  6. Caused by: java.lang.IllegalStateException: javax.websocket.server.ServerContainer not available

    java.lang.IllegalStateException: Failed to load ApplicationContext    at org.springframework.test.co ...

  7. 错误:Camera录制视频(6.0错误),5.1正常,7.1正常 (java.lang.RuntimeException: start failed.at android.media.MediaRecorder.native_start(Native Method))

    Process: com.example.mycamera2, PID: 24086 java.lang.RuntimeException: start failed. at android.medi ...

  8. Caused by: java.lang.IllegalStateException: duplicate key: datasource

    java.lang.IllegalStateException: Failed to load property source from location 'classpath:/applicatio ...

  9. Caused by: java.lang.IllegalStateException: Ambiguous mapping found

    Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Cannot map ‘myCockpitMgrControl ...

随机推荐

  1. 使用memcache处理缓存的三种方案

    这篇文章主要讨论的问题是:如何为项目设计一个完整而简洁的缓存系统.只讲做法,不讲原理.在我们项目中,使用到了三种方法,来保证了缓存系统的有效简洁. 1) 第一种,最常见的方式 读取数据的主要步骤如下: ...

  2. 如何设置Linux swap分区

    看到不少朋友问linux下swap分区的问题,收集到一篇 不错的文章 ,分享下.什么是Swap?Swap,即交换区,除了安装Linux的时候,有多少人关心过它呢?其实,Swap的调整对Linux服务器 ...

  3. 抛弃百度UMEditor,拥抱summernote (解决上传文件又慢又卡的问题)

    由于一些项目上的原因以及相关因素,我们使用其他富文本编辑器替代了UMEditor 本来用CKEditor,但是团队觉得使用起来很不顺手,尤其图片上传十分不爽,功能复杂但是使用起来比较麻烦 后来我们又替 ...

  4. 通过反射实现圆角ImageView

    private void init(){ paint = new Paint(Paint.ANTI_ALIAS_FLAG); roundRect = , , getWidth() , getHeigh ...

  5. sql server2000导出表结构说明

    SELECT 表名 then d.name else '' end, 表说明 then isnull(f.value,'') else '' end, 字段序号=a.colorder, 字段名=a.n ...

  6. [Windows Azure] How to Scale an Application

    How to Scale an Application To use this feature and other new Windows Azure capabilities, sign up fo ...

  7. ubuntu mysql 远程连接问题解决方法

    在shell下输入mysql -uroot -p是可以登录的,所以问题应该是mysql不允许root用户远程登录的问题,于是通过输入下面命令: GRANT ALL PRIVILEGES ON *.*  ...

  8. 多媒体文件格式之TS

    [时间:2016-07] [状态:Open] TS流是MPEG-2标准中定义一种用于直播的码流结构,具有很好的容错能力.所有跟TS相关的标准可以从ISO/IEC_13818-1中找到. 通常TS流的后 ...

  9. LeetCode: Add Two Numbers 解题报告

    Add Two NumbersYou are given two linked lists representing two non-negative numbers. The digits are ...

  10. Android开发(十)——像素单位dp、px、pt、sp的比较

    dp(dip): device independent pixels(设备独立像素). 不同设备有不同的显示效果,这个和设备硬件有关,一般我们为了支持WVGA.HVGA和QVGA 推荐使用这个,不依赖 ...