0
votes

When playing an audio file in watchOS (using SpriteKit):

run(SKAction.playSoundFileNamed("ready.wav", waitForCompletion:false))

It will works until you background the app (says face the watch outwards) and back, then the audio file cannot be played anymore.

I have tried many workarounds, including setting UIBackgroundModes to audio, but the sound will always stop working after the app is background and back. Any solution?

PS: I think I might have found the answer: use AVAudioPlayer instead of SKAction.

2

2 Answers

0
votes

You need to start HKWorkoutSession and in info.plist enable workout background processing. Don't need the audio to play in background, just continue to play once it comes back from background.

0
votes

Use AVAudioPlayer instead of SKAction. This works.

Only SKAction.playSoundFileNamed has this issue.