MediaPlayer的切断播放为时过早棒棒糖当屏幕关闭为时过早、棒棒糖、屏幕、MediaPlayer

2023-09-05 08:36:53 作者:别要做痴情种

我一直运行到的棒棒糖设备的问题与MediaPlayer的。基本上当设备屏幕处于关闭状态(即用户锁定装置)回放继续,但结束约1 - 太早了2秒。当屏幕上,虽然这不会发生。

I've been running into an issue with the MediaPlayer on Lollipop devices. Basically when the device screen is off (i.e. user locked the device) the playback continues, but ends about 1 - 2 seconds too early. This doesn't happen when the screen is on though.

我有一个onCompletionListener上的MediaPlayer的:

I have an onCompletionListener on the MediaPlayer:

@Override
public void onCompletion(final MediaPlayer mediaPlayer) {
    int progress = mediaPlayer.getCurrentPosition();
    int duration = mediaPlayer.getDuration();
    Log.d("PlaybackController", "progress: " + progress + " duration: " + duration);
    Log.d("PlaybackController", "Delay: " + (duration - progress)); // I'm seeing a difference of 1 - 3 seconds :(.
    mServiceHandler.postDelayed(new Runnable() {
        @Override
        public void run() {
            broadcastCompleted();
        }
    }, Math.max(duration - progress, 0));
}

这通常会打印:延迟:[1500 - 3000] 。我在想,如果有一个唤醒锁我失踪​​,但我正在这里所说的正确的锁:的 http://developer.android.com/guide/topics/media/mediaplayer.html ,该包括一个PARTIAL_WAKE_LOCK和WifiLock。有没有别的东西我失踪?

This usually prints: Delay: [1500 - 3000]. I was wondering if there was a wake lock I'm missing, but I'm making the correct locks mentioned here: http://developer.android.com/guide/topics/media/mediaplayer.html, which include a PARTIAL_WAKE_LOCK and a WifiLock. Is there something else I'm missing?

推荐答案

好了,它看起来像这个问题的是Android 5.0.1的实验性的MediaPlayer称为NuPlayer。 NuPlayer被默认启用所有的Andr​​oid 5.0.1设备,并且只能通过开发人员选项被禁用。我提出一个bug对机器人在这里:的https://$c$c.google.com/p/android/issues/detail?id=94069&thanks=94069&ts=1420659450

Ok it looks like the issue is Android 5.0.1's experimental MediaPlayer called NuPlayer. NuPlayer is being enabled by default on all Android 5.0.1 devices and is only disabled through Developer Options. I've filed a bug against Android here: https://code.google.com/p/android/issues/detail?id=94069&thanks=94069&ts=1420659450

下面是你可以把你的用户,当他们面临着在Android 5.0.1设备的媒体播放问题的样本电邮:

Here's a sample email you can send your users when they face issues with Media playback on Android 5.0.1 devices:

看起来这可能是对Android的新的实验性的MediaPlayer称为NuPlayer的错误。为了解决这个问题,请按照下列步骤操作:

It looks like this might be a bug on Android's new experimental MediaPlayer called NuPlayer. To fix this, please follow these steps:

转到Android设置 进入关于手机 向下滚动到内部版本号,然后点击版本号7次。 您会看到一条消息,说:你现在是X几步之遥,从一个开发者。 点击它7次会后说:你现在是开发者! Go to Android Settings Go to "About Phone" Scroll down to "Build Number" and tap the Build number 7 times. You'll see a message saying "you are now X steps away from being a developer". After tapping it 7 times it will say "You are now a developer!"