Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to play a sound for watch kit app

Tags:

ios

watchkit

From what I understand it is currently not possible to play a sound from your watch kit app on the watch. If this is the case what is the best way to play a sound? Currently I am using openParentApplication:reply: to run code on the phone that plays the sound. Is this the best way?

Update: I also found that I can play audio directly from the watch extension using the same methods as in the parent app. No Idea if this will actually play when not on the simulator.

like image 579
datinc Avatar asked Feb 20 '15 22:02

datinc


Video Answer


1 Answers

There currently isn't any way to play audio on the Watch. Your assumptions are 100% correct. Apple doesn't want to have to transfer the audio clips from the Watch Extension to the Watch at runtime. Currently, the only supported transfer caching system is for images. For now, you will have to play the audio on the iOS device. You can use one of the following approaches to trigger playing the sound:

  • openParentApplication:reply: - opens app in the background if not currently running
  • Darwin notifications through something like MMWormhole

Playing the sound from the Watch extension is certainly a gray area. My guess is that it will play on the iOS Device or not play at all when testing with devices. I would certainly advise against that approach though. Your Watch Extension will typically only be open for a VERY short period of time. It would be a much better idea to play the audio from the iOS app since that is guaranteed to continue running.

like image 64
cnoon Avatar answered Sep 28 '22 11:09

cnoon