Posts

Post not yet marked as solved
0 Replies
568 Views
I am developing a WatchOS app for a companion Bluetooth speaker.The device has typical the Play/Pause, Volume Up and Volume Down keys of a usual Bluetooth Speaker.The following code works great at playing the audio, and I can control the volume using the up and down keys, but for some reason I can only stop the audio player using the Play/Pause button on the device. If I try to press the Play/Pause button again, nothing happens.func playSong(song: Song) { do { try self.session.setCategory(AVAudioSession.Category.playback, mode: .default, policy: .longFormAudio, options: []) } catch let error { fatalError("*** Unable to set up the audio session: \(error.localizedDescription) ***") } do { print("Attempting to play ", song.url) let newPlayer = AVPlayer(url: song.url) newPlayer.play() self.player = newPlayer } catch let error as NSError { print(error.description) } }Is there a function or method I can listen on in order to implement the expected play/pause functionality?I expect I'll have to handle the self.player.pause() events myself, which is no problem, but I can't find any reference for handling any Bluetooth Media Key events (except for the global Play Pause it seems).
Posted
by jarek319.
Last updated
.