Guest User

Untitled

a guest
Feb 20th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. NSMutableDictionary *nowPlayingInfo = [[NSMutableDictionary alloc] init];
  2. [nowPlayingInfo setObject:track.artistName forKey:MPMediaItemPropertyArtist];
  3. [nowPlayingInfo setObject:track.trackTitle forKey:MPMediaItemPropertyTitle];
  4. ...
  5. [nowPlayingInfo setObject:[NSNumber numberWithDouble:self.player.rate] forKey:MPNowPlayingInfoPropertyPlaybackRate];
  6. [nowPlayingInfo setObject:[NSNumber numberWithDouble:self.currentPlaybackTime] forKey:MPNowPlayingInfoPropertyElapsedPlaybackTime];
  7. [MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo = nowPlayingInfo;
  8.  
  9. NSMutableDictionary *nowPlayingInfo = [[MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo mutableCopy];
  10. [nowPlayingInfo setObject:[NSNumber numberWithDouble:self.player.rate] forKey:MPNowPlayingInfoPropertyPlaybackRate];
  11. [nowPlayingInfo setObject:[NSNumber numberWithDouble:self.currentPlaybackTime] forKey:MPNowPlayingInfoPropertyElapsedPlaybackTime];
  12. [MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo = nowPlayingInfo;
  13.  
  14. - (NSTimeInterval)currentPlaybackTime {
  15. CMTime time = self.player.currentTime;
  16. if (CMTIME_IS_VALID(time)) {
  17. return time.value / time.timescale;
  18. }
  19. return 0;
  20. }
  21.  
  22. [nowPlayingInfo setObject:[track valueForProperty: MPMediaItemPropertyPlaybackDuration]
  23. forKey:MPMediaItemPropertyPlaybackDuration];
  24.  
  25. - (void) remoteControlReceivedWithEvent: (UIEvent *) receivedEvent
  26.  
  27. if (receivedEvent.subtype == UIEventSubtypeRemoteControlBeginSeekingBackward){};
  28. if (receivedEvent.subtype == UIEventSubtypeRemoteControlBeginSeekingForward){};
  29. if (receivedEvent.subtype == UIEventSubtypeRemoteControlEndSeekingBackward){};
  30. if (receivedEvent.subtype == UIEventSubtypeRemoteControlEndSeekingForward){};
  31.  
  32. [MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo
  33.  
  34. [player currentTime]
  35.  
  36. [nowPlayingInfo setObject:[player currentTime]
  37. forKey:MPNowPlayingInfoPropertyElapsedPlaybackTime];
  38. [nowPlayingInfo setObject:[[NSNumber alloc] initWithFloat:10]
  39. forKey:MPNowPlayingInfoPropertyPlaybackRate];
  40.  
  41. [player setRate:10]
  42.  
  43. MPChangePlaybackPositionCommand *changePlaybackPositionCommand = [[MPRemoteCommandCenter sharedCommandCenter] changePlaybackPositionCommand];
  44. [changePlaybackPositionCommand addTarget:self action:@selector(changePlaybackPositionEvent:)];
  45. [[MPRemoteCommandCenter sharedCommandCenter].changePlaybackPositionCommand setEnabled:YES];
  46.  
  47. [yourPlayer seekTo:event.positionTime completionHandler:^(BOOL finished) {
  48. [self updatePlaybackRateMetadata];
  49. }];
Add Comment
Please, Sign In to add comment