MediaPlayer 中的错误:E/MediaPlayer:错误 (1,-19) - Android
Error in MediaPlayer : E/MediaPlayer: Error (1,-19) - Android
我知道有一些类似的问题,但是 none 回答了我的问题。当我点击一个按钮时,媒体播放器被调用,这出现在日志中。
06-02 00:20:38.980 26035-26035/myapp.com.facadezpontos E/MediaPlayer-JNI: QCMediaPlayer mediaplayer NOT present
06-02 00:20:39.019 26035-26035/myapp.com.facadezpontos E/MediaPlayer: Should have subtitle controller already set
06-02 00:20:39.026 26035-26035/myapp.com.facadezpontos E/MediaPlayer: Should have subtitle controller already set
一段时间后,上面的消息被下面的消息代替,媒体播放器提供的声音不再播放。
06-02 00:23:21.032 28749-28749/myapp.com.facadezpontos E/MediaPlayer-JNI: QCMediaPlayer mediaplayer NOT present
06-02 00:23:21.076 28749-28749/myapp.com.facadezpontos E/MediaPlayer: Should have subtitle controller already set
06-02 00:23:21.090 28749-28749/myapp.com.facadezpontos E/MediaPlayer: Should have subtitle controller already set
06-02 00:23:21.396 28749-28772/myapp.com.facadezpontos E/MediaPlayer: error (1, -19)
06-02 00:23:21.396 28749-28749/myapp.com.facadezpontos E/MediaPlayer: Error (1,-19)
这是 MediaPlayer 的代码
public void buttonClick(Context context, MediaPlayer mp){
mp = MediaPlayer.create(context, R.raw.bubble_nice);
mp.start();
}
我解决了问题!
我改变了调用声音文件的方式,这是我的做法。
我将文件放入资产中以使其正常工作。
if(mp.isPlaying())
{
mp.stop();
}
try {
mp.reset();
AssetFileDescriptor afd;
afd = getAssets().openFd("AudioFile.mp3");
mp.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(),afd.getLength());
mp.prepare();
mp.start();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
我从这里得到的:android - how to make a button click play a sound file every time it been pressed?
我知道有一些类似的问题,但是 none 回答了我的问题。当我点击一个按钮时,媒体播放器被调用,这出现在日志中。
06-02 00:20:38.980 26035-26035/myapp.com.facadezpontos E/MediaPlayer-JNI: QCMediaPlayer mediaplayer NOT present
06-02 00:20:39.019 26035-26035/myapp.com.facadezpontos E/MediaPlayer: Should have subtitle controller already set
06-02 00:20:39.026 26035-26035/myapp.com.facadezpontos E/MediaPlayer: Should have subtitle controller already set
一段时间后,上面的消息被下面的消息代替,媒体播放器提供的声音不再播放。
06-02 00:23:21.032 28749-28749/myapp.com.facadezpontos E/MediaPlayer-JNI: QCMediaPlayer mediaplayer NOT present
06-02 00:23:21.076 28749-28749/myapp.com.facadezpontos E/MediaPlayer: Should have subtitle controller already set
06-02 00:23:21.090 28749-28749/myapp.com.facadezpontos E/MediaPlayer: Should have subtitle controller already set
06-02 00:23:21.396 28749-28772/myapp.com.facadezpontos E/MediaPlayer: error (1, -19)
06-02 00:23:21.396 28749-28749/myapp.com.facadezpontos E/MediaPlayer: Error (1,-19)
这是 MediaPlayer 的代码
public void buttonClick(Context context, MediaPlayer mp){
mp = MediaPlayer.create(context, R.raw.bubble_nice);
mp.start();
}
我解决了问题!
我改变了调用声音文件的方式,这是我的做法。
我将文件放入资产中以使其正常工作。
if(mp.isPlaying())
{
mp.stop();
}
try {
mp.reset();
AssetFileDescriptor afd;
afd = getAssets().openFd("AudioFile.mp3");
mp.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(),afd.getLength());
mp.prepare();
mp.start();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
我从这里得到的:android - how to make a button click play a sound file every time it been pressed?