Play sound from Apple Watch speaker

4 Solutions Collect From Internet About “Play sound from Apple Watch speaker”

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];

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

  • presentMediaPlayerControllerWithURL:options:completion:
    (New in watchOS 2.0)

URL
The URL of the media file you want to play. The URL must specify a file; streamed media is not supported. The file may contain audio, video, or both.

If you specify a URL for a file on a remote server, this method downloads the file first and displays a progress indicator showing the progress of the operation. Because WatchKit uses App Transport Security (ATS) when downloading files from a web server, the file must be on a secure server, and the URL must use the https scheme. If your server does not support ATS–level security, download the file yourself before playing it.

Use sharedcontainer, watch extensions, for storing the file.

Any audio you play using this method is routed to a paired Bluetooth audio device if one is available. If no Bluetooth audio device is available, audio is routed to to the Apple Watch speaker.

For WatchOS3 the answer to the original question is WKInterfaceInlineMovie
https://developer.apple.com/reference/watchkit/wkinterfaceinlinemovie

You can hide the widget so it does not alter your interface design. It plays audio files through the watch’s speaker if no bluetooth speaker is connected.