【问题标题】:Error in MediaPlayer : E/MediaPlayer: Error (1,-19) - AndroidMediaPlayer 中的错误:E/MediaPlayer:错误 (1,-19) - Android
【发布时间】:2017-06-02 03:29:17
【问题描述】:

我知道有一些类似的问题,但没有一个回答我的问题。当我单击一个按钮时,会调用媒体播放器,这会出现在日志中。

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)

这是媒体播放器的代码

public void buttonClick(Context context, MediaPlayer mp){
        mp = MediaPlayer.create(context, R.raw.bubble_nice);
        mp.start();
    }

【问题讨论】:

标签: java android media-player


【解决方案1】:

我解决了这个问题!

我改变了调用声音文件的方式,我是这样做的。

我将文件放在资产中以使其正常工作。

    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?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-17
    • 2015-09-18
    • 2013-09-20
    相关资源
    最近更新 更多