Learn Courses My Dashboard

Sound not playing on certain devices

My app will play all the correct sound files in the simulator and canvas on ‘iPhone12 Pro Max’ but not on other devices. On all devices it will play sound files on the ‘Settings’ page of the app but nowhere else except for the ‘iPhone12 Pro Max’. The ‘Settings’ page is where I have a mute button which seems to be working as intended. Everything was working fine a few days ago but not now. I tried an older version of the app but had the same issue. I have tried resetting my laptop and even uninstalled then re-installed Xcode but no luck.

I wont post any code yet, just wanted to see if anyone had any thoughts?

It would be very helpful to always post your code.

Check the settings for the simulator that the “sound” is on

What would I be looking for in device settings that might affect my app?

I am calling the play sound method on appear or on a button tap like this

.onAppear { self.soundEffectsM.playSound(sound: "GunCock", type: "wav") }
.onAppear(perform: {self.soundEffectsM.playSound(sound: "Band", type: "wav") })
Button(action: {
                    if UserDefaults.standard.bool(forKey: "seOn") == true { self.soundEffectsM.playSound(sound: "GunShot", type: "wav") }

As you can see i have tried to write them in different ways but get the same results. Interestingly the app is currently now working on the simulator in all devices however i still get the same issue when trying to play on a real device (iPhone 7). The phone is updated as well.

What Mikaela is suggesting is to check that the volume on your device is set to an appropriate level. If you have already checked that then the issue is obviously elsewhere.

Simulators are not necessarily preset to some mid level volume so to raise the volume on a simulator, hold the Command key and tap up arrow or down arrow.

Ok I didn’t even realise that was possible. I still have the same problem. Seems to pick and choose what to play correctly. Currently sound works on my ‘Settings’ page across all devices but will only correctly play all sounds on iPhone8 and above.