0

I am simulating my game on my iPad Air iOS 9.1 produced using XCode 7.3 beta and Swift 2.2 Spritekit I am using sounds via

SKAction.playSoundFileNamed(_: string)

whenever I start the game for the first time ; including going home screen then back to game ; the first played audio is very low or seems destructed. Also I tried simulating premade games by other developers having the same problem .

Maybe a bug of the beta version of Xcode ?

Whirlwind
  • 14,286
  • 11
  • 68
  • 157
Fadi
  • 733
  • 1
  • 5
  • 17
  • Can you provide more context ... What type of audio file you use ? Add some more code. I can't reproduce what you are saying (I am on Xcode 7.1.1 though). – Whirlwind Apr 16 '16 at 11:20
  • I am using .wav sound formats . Code is not the issue , I've tried other pretested projects. I am using a beta version of Xcode 7.3 – Fadi Apr 16 '16 at 15:51
  • Possible duplicate of [Simple low-latency audio playback in iOS Swift](http://stackoverflow.com/questions/34680007/simple-low-latency-audio-playback-in-ios-swift) – Fadi Dec 14 '16 at 10:33

2 Answers2

0

I am not very familiar with SKAction but you can use prepareToPlay() on viewDidLoad or AppDelegate then you can play it when you need it.

  • Also, the m4a format will be faster than mp3.

You can find full code example in here: https://stackoverflow.com/a/34981944/2125010

Community
  • 1
  • 1
fatihyildizhan
  • 8,614
  • 7
  • 64
  • 88
  • He is using `SKAction.playeSoundFileNamed()` not `AVAudioPlayer`, so there is no [prepare](https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVAudioEngine_Class/#//apple_ref/occ/instm/AVAudioEngine/prepare) method in that case (if that is what you've meant). – Whirlwind Apr 16 '16 at 11:15
0

I had the same issue. Playing silent sound when game becomes active resolves that.

GRiMe2D
  • 654
  • 1
  • 10
  • 22
  • I thought of that at first , but I think we should look for a cure not a symptomatic relief . – Fadi Apr 16 '16 at 12:05