发行使用setNextMediaPlayer音频播放 [英] Issue with audio playback using setNextMediaPlayer

查看:243
本文介绍了发行使用setNextMediaPlayer音频播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要播放音频而不截枝之间的缝隙,声音需要被无间隙永远循环。使用 setNextMediaPlayer 仅合并两个音轨无间隙,它会自动停止播放音频后,它不是循环,直到永远。提前致谢。

  MP1 = MediaPlayer.create(getApplicationContext(),R.raw.loop);
    MP2 = MediaPlayer.create(getApplicationContext(),R.raw.loop);保护无效播放(){
    // TODO自动生成方法存根    mp1.start();
    mp1.setNextMediaPlayer(MP2);
    // mp2.setNextMediaPlayer(MP1);}


解决方案

我试图帮助一个人做的,只是前几天。请参见这个问题

我不知道他是否能够达到他想要的东西,但我相信你的问题是,的MediaPlayer 不在ppared状态后,$ P $第二赛道结束。您将需要使用 onCompletion 监听器将其返回到调用ppared状态$ P $ 停止() prepareAsync()。如果没有需要是在prepared状态(我真的不知道),这将是更快地从调用 seekTo(0) onCompletion 监听器。

您一定要取消对 mp2.setNextMediaPlayer(MP1);

I need to play an audio without gaps between lopping, the audio needs to be looped forever without gaps. Using setNextMediaPlayer only merge two audio tracks without gaps, after that it automatically stops playing the audio, it is not looping for ever. Thanks in advance.

    mp1 = MediaPlayer.create(getApplicationContext(), R.raw.loop);
    mp2 = MediaPlayer.create(getApplicationContext(), R.raw.loop);

protected void play() {
    // TODO Auto-generated method stub

    mp1.start();
    mp1.setNextMediaPlayer(mp2);
    // mp2.setNextMediaPlayer(mp1);

}

解决方案

I tried to help a guy do that just a few days ago. See this question.

I'm not sure if he was able to achieve what he wanted, but I believe your problem is that the MediaPlayer is not in the prepared state after the 2nd track finishes. You will need to use the onCompletion listener to return it to the prepared state by calling stop() and prepareAsync(). If it doesn't need to be in the prepared state (I'm honestly not sure), it would be faster to call seekTo(0) from the onCompletion listener.

You will definitely need to uncomment the mp2.setNextMediaPlayer(mp1); line.

这篇关于发行使用setNextMediaPlayer音频播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆