MediaPlayer的不会循环。 setLooping()不工作工作、MediaPlayer、setLooping

2023-09-09 21:13:58 作者:流年相摧,花依旧人不复﹌

m_MediaPlayer = MediaPlayer.create(context, soundFromResource);
m_MediaPlayer.setVolume(0.99f, 0.99f);
m_MediaPlayer.setLooping(true);
m_MediaPlayer.setOnCompletionListener(USoundPlayback.this);
m_MediaPlayer.start();

我像上面测试过,我也通过调用测试它 setLooping(真)开始(),但没有运气。

我有两个的Nexus 5 手机,都与 Android的5 在他们身上。在一体,循环工程,对其他的声音一气呵成后停止,也不会循环。

I have two Nexus 5 phones, both with Android 5 on them. On one, the looping works, on the other the sound stops after one go, it won't loop.

任何想法?!

推荐答案

显然有一个与 Android的5 它们使用的设备的问题 NuPlayer 而不是 AwesomePlayer

Apparently there's an issue with Android 5 devices which use the NuPlayer instead of the AwesomePlayer.

您可以在开发人员选项会检查,在新闻部分应该有使用NuPlayer(实验)。我已经选中了,看来现在是正常的。

You can check it by going in the Developer Options, under the Media section there should be Use NuPlayer (experimental). I've unchecked that and it appears it's alright now.

我一直无法弄清楚如何来解决这个问题,所以我砍死了一点。我在code设置一些标志,当它进入 onCompletion ,如果用户没有明确停止的声音,我重新启动它。如果有任何人有更好的修复,让我知道,我会更新这个答案。

I haven't been able to figure out how to fix this issue, so I've hacked it a bit. I've set some flags in the code and when it enters onCompletion, if the user hasn't specifically stopped the sound, i restart it there. If there's anyone with a better fix, let me know and i'll update this answer.

下面的问题: HTTPS://$c$c.google.com/p/android-developer-$p$pview/issues/detail ID = 1695