0 Replies
      Latest reply on Dec 1, 2019 6:28 PM by jarek319
      jarek319 Level 1 Level 1 (0 points)

        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)
                    self.player = newPlayer
                } catch let error as NSError {


        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).