teodorpatras / Jukebox

Player for streaming local and remote audio files. Written in Swift.
MIT License
551 stars 122 forks source link

Remote control play/pause not responding in example - add RemoteControlTogglePlayPause event? #3

Closed antiero closed 8 years ago

antiero commented 8 years ago

Just found something with remote control events which might be nice to add in your ViewController example...

'RemoteControlPlay' and 'RemoteControlPause' UIEvents don't get called if you press headphone remote button or play/pause on the lock screen. It's the .RemoteControlTogglePlayPause one which gets called, so maybe adding something like this would be helpful?

override func remoteControlReceivedWithEvent(event: UIEvent?) { if event?.type == .RemoteControl { switch event!.subtype { case .RemoteControlPlay : self.jukeBox.play() case .RemoteControlTogglePlayPause : print("Toggle Play/Pause received") self.playPauseAction()

I'd also consider moving the default example override func remoteControlReceivedWithEvent into the core Jukebox.swift, as you're already calling beginReceivingRemoteControlEvents when Jukebox is initialised and the example calls through to the expected Jukebox play/pause/next/previous methods already.. just for convenience maybe :)

teodorpatras commented 8 years ago

unfortunately the remote event is propagated through the responder chain so i cannot intercept it inside of Jukebox, readme updated. thanks for the input and sorry for the late reply.