Is there a way to play sound out of the Apple Watch's speaker? I have been unable to find any documentation online.
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.
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];
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With