使用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. spark-submit的参数名称解析

    执行时需要传入的参数说明 Usage: spark-submit [options] <app jar | Python file> [app options] 参数名称 含义 --mas ...

  2. Rational Rose 2003 下载及破解方法

    FROM:http://blog.csdn.net/fenglibing/archive/2007/08/17/1747693.aspx 这么好的东西,不拿来出分享,我对不起原作者呀.但是我这里不知道 ...

  3. 解决Unity协程无法同步返回的问题

    Unity的协程是轻量的异步解决方案,但是每调用一次yield就必须等下一帧才能继续,这一点带来了很多约束. 比如如下代码: void OnEnable() { StartCoroutine(_Do( ...

  4. ubuntu for win10 里运行net core

    花了点时间在ubuntu for win10里运行net core 按官网上ubuntun10.14装的net core指令 ...... ...... sudo apt-get install do ...

  5. UIViewContrller之间切换的几种方式

    转自:http://blog.csdn.net/likendsl/article/details/7542296   1.UIViewContrller之间的切换有三种方式:     一.UIView ...

  6. Win7 下面升级VS2017 vs_community install Microsoft.Windows.D3DCompiler.Msu.Win7

    因为.NET Framework 4.7 WPF 功能采用D3DCompiler_47.dll依赖项.默认情况下,此 D3DCompiler_47.dll 并不是存在于 Windows 7 SP1,W ...

  7. vscode 换行符\n 变成\r\n

    VSCode是一个开源的强大代码编写器,但是如果没有好好的配置使用,会适得其反. 这里总结VSCode的一些配置,方便自己查询,也方便网友. 1.编辑器配置 为特定类型文件指定缩进大小.缩进类型(空格 ...

  8. 每日英语:Why Mom's Time Is Different From Dad's Time

    Several years ago, while observing a parenting group in Minnesota, I was struck by a confession one ...

  9. 每日英语:China's Wistful Wen Gets His Wish

    As his term as premier was drawing to a close, Wen Jiabao reflected wistfully on some of the goals h ...

  10. Erlang中一些错误或者异常的标识

    erlang中错误大体分为四种: 1. 编译错误    2. 逻辑错误    3. 运行时错误    4. 用户代码生成的错误 编译错误,主要是编译器检测出的代码语法错误 逻辑错误,是指程序没有完成预 ...