标签:lin 调用 color col eth and lang reset media
使用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)
标签:lin 调用 color col eth and lang reset media
原文地址:https://www.cnblogs.com/Sharley/p/9267423.html