0

我已经使用以下代码实现了 MediaPlayer,但它从不调用onCompletion. 我正在从我的 LAN 流式传输 mp3。知道有什么问题吗?

mMediaPlayer = new MediaPlayer();
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mMediaPlayer.setOnPreparedListener(new OnPreparedListener()
{
    @Override
    public void onPrepared(MediaPlayer mp)
    {
        mMediaPlayer.start();
    }
});
mMediaPlayer.setOnCompletionListener(new OnCompletionListener()
{
    @Override
    public void onCompletion(MediaPlayer mp)
    {
        // Nothing here gets executed
        mMediaPlayer.start();
    }
});

mMediaPlayer.reset();
mMediaPlayer.setDataSource(url);
mMediaPlayer.prepareAsync();
4

0 回答 0