I have my MPNowPlayingInfoCenter up and running but one problem remains. regardless of my actual player state the MPNowPlayingInfoCenter is always "playing" and displays the pause button. When pressed it fires the pause event.

When my player changes state, for example to paused, i update the MPNowPlayingInfoCenter via the MPNowPlayingInfoPropertyPlaybackRate key.

Is there any other way to set the MPNowPlayingInfoCenter state to paused?

Any hints appreciated!

有帮助吗?

解决方案 2

Found out the issue was when a second source of audio output was playing while my included media player was controlled via nowplayingcenter it somehow ignored my manually set playback rate and detected audio playing.

So the solution for me was to pause the second audio as well. In my situation this was possible but i don't know how to overcome this when the second audio is critical for the app. I'll happily accept any answer which solves this issue more elegantly.

其他提示

Try this:

 NSMutableDictionary *currentlyPlayingTrackInfo = [NSMutableDictionary dictionaryWithCapacity:7];
 currentlyPlayingTrackInfo[MPNowPlayingInfoPropertyElapsedPlaybackTime] = @((Float64)[player currentTime]);
    if (!SYSTEM_VERSION_OF_DEVICE_LESS_THAN(@"7.0"))
    {
        currentlyPlayingTrackInfo[MPNowPlayingInfoPropertyPlaybackRate] = [NSNumber numberWithDouble:_isHere == NO?1:0];
    }
    else
    {
        currentlyPlayingTrackInfo[MPNowPlayingInfoPropertyPlaybackRate] = [NSNumber numberWithDouble:1];
    }
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:currentlyPlayingTrackInfo];
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top