Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. fileprivate func invalidatePlayback(shouldResetIndex resetIndex: Bool = true) {
  2. stopProgressTimer()
  3. radioPlayer?.pause()
  4. radioPlayer?.rate = 0.0
  5. state = .paused
  6. radioPlayer = nil
  7.  
  8. if resetIndex {
  9. playIndex = 0
  10. }
  11. }
  12.  
  13. fileprivate func startNewPlayer(forItem item : AVPlayerItem) {
  14. invalidatePlayback(shouldResetIndex: false)
  15. radioPlayer = AVPlayer(playerItem: item)
  16. radioPlayer?.allowsExternalPlayback = false
  17. radioPlayer?.rate = 1.0
  18. startProgressTimer()
  19. seek(toSecond: 0, shouldPlay: true)
  20. updateInfoCenter()
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement