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

Posted Sharley

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Caused by:java.lang.IllegalStateException at android.media.MediaPlayer._setDataSource(Native Method)相关的知识,希望对你有一定的参考价值。

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

Caused by: java.lang.IllegalStateException
at android.media.MediaPlayer._setDataSource(Native Method)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1383)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1367)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1302)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1240)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:986)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:951)
...

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

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

 

以上是关于Caused by:java.lang.IllegalStateException at android.media.MediaPlayer._setDataSource(Native Method)的主要内容,如果未能解决你的问题,请参考以下文章

Mathematical Problems Caused by CCD

Caused by SSLError

Caused by: java.lang.NoClassDefFoundError:

caused by a circular import.

异常Caused by: java.lang.ClassNotFoundException: org.springframework.dao.DataIntegrityViolationExcep

Caused by org hibernate DuplicateMappingException Duplicat