Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play sound from Apple Watch speaker

Is there a way to play sound out of the Apple Watch's speaker? I have been unable to find any documentation online.

like image 655
frenchie4111 Avatar asked Mar 11 '15 06:03

frenchie4111


People also ask

Does Apple Watch have internal speaker?

Send a call to voicemail: Tap the red Decline button in the incoming call notification. Answer on your Apple Watch: Tap the Answer button to talk using the built-in microphone and speaker or a Bluetooth device paired with your Apple Watch.


3 Answers

This is now possible as of watchOS 2 using WKAudioFilePlayer or WKInterfaceMovie.

NSURL *assetURL = [[NSBundle mainBundle] URLForResource:@"file" withExtension:@"wav"];

WKAudioFilePlayer example:

WKAudioFileAsset *asset = [WKAudioFileAsset assetWithURL:assetURL];
WKAudioFilePlayerItem *playerItem = [WKAudioFilePlayerItem playerItemWithAsset:asset];
WKAudioFilePlayer *audioFilePlayer = [WKAudioFilePlayer playerWithPlayerItem:playerItem];
[audioFilePlayer play];

WKInterfaceMovie example:

[self presentMediaPlayerControllerWithURL:assetURL options:nil completion:nil];
like image 131
Ric Santos Avatar answered Oct 15 '22 05:10

Ric Santos


import AVFoundation
var player: AVAudioPlayer?

if let path = Bundle.main.path(forResource: "siren", ofType: "wav") {

        let fileUrl = URL(fileURLWithPath: path)

        do{
            try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
            try AVAudioSession.sharedInstance().setActive(true)

            player = try AVAudioPlayer(contentsOf: fileUrl)

            guard let player = player else { return }

            player.play()

        }
        catch
        {

        }

    }

I've used this to play a custom sound from the apple watch(4.3) speaker and worked just fine. Don't forget to set the audio file target membership to the watch kit.

like image 27
Rafael Bonini Avatar answered Oct 15 '22 05:10

Rafael Bonini


It is not possible to play sound out of the Apple Watch's speaker, but you can trigger playing a sound file on the iPhone, here is thread about it

like image 3
sheraza Avatar answered Oct 15 '22 04:10

sheraza