Note that there are some explanatory texts on larger screens.

plurals
  1. POMPNowPlayingInfoCenter not reacting properly when pausing playback
    primarykey
    data
    text
    <p>I am trying to get MPNowPlayingInfoCenter to work properly when pausing playback. (I have a streaming music app that uses AVPlayer for playback, and I am playing back in my Apple TV over Airplay.) Everything but pausing seems to be reflected correctly in the Apple TV UI. I am initializing it like this:</p> <pre><code>MPNowPlayingInfoCenter *center = [MPNowPlayingInfoCenter defaultCenter]; NSDictionary *songInfo = @{ MPMediaItemPropertyTitle: title, MPMediaItemPropertyArtist: artist }; center.nowPlayingInfo = songInfo; </code></pre> <p>Since I am streaming, I do not have duration info upon starting the playback. When I get “ready” signal from the stream, I update the duration that shows up correctly on my Apple TV:</p> <pre><code>MPNowPlayingInfoCenter *center = [MPNowPlayingInfoCenter defaultCenter]; NSMutableDictionary *playingInfo = [NSMutableDictionary dictionaryWithDictionary:center.nowPlayingInfo]; [playingInfo setObject:[NSNumber numberWithFloat:length] forKey:MPMediaItemPropertyPlaybackDuration]; center.nowPlayingInfo = playingInfo; </code></pre> <p>I can also seek with this technique when the user seeks the track:</p> <pre><code>[playingInfo setObject:[NSNumber numberWithFloat:length * targetProgress] forKey:MPNowPlayingInfoPropertyElapsedPlaybackTime]; </code></pre> <p>The one thing I can NOT figure out is, how to pause the playhead on my Apple TV. When user taps pause in my UI, I am trying to do something like:</p> <pre><code>MPNowPlayingInfoCenter *center = [MPNowPlayingInfoCenter defaultCenter]; NSMutableDictionary *playingInfo = [NSMutableDictionary dictionaryWithDictionary:center.nowPlayingInfo]; [playingInfo setObject:[NSNumber numberWithFloat:0.0f] forKey:MPNowPlayingInfoPropertyPlaybackRate]; center.nowPlayingInfo = playingInfo; </code></pre> <p>Instead of pausing, this seeks the playhead back to zero and keeps advancing it.</p> <p>How do I get the playhead to pause correctly in my Apple TV UI?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload