Ttrentler
Ttrentler

Reputation: 61

Playing a System sound in tvos [swift]

In iOS I can play a system sound with the following code:

// import this
import AVFoundation

// create a sound ID, in this case its the tweet sound.
let systemSoundID: SystemSoundID = 1016

// to play sound
AudioServicesPlaySystemSound (systemSoundID)

There is this link https://github.com/TUNER88/iOSSystemSoundsLibrary to a list of available system sounds in iOS

My question is are system sounds available in tvOS? and which ones are available.

Upvotes: 4

Views: 956

Answers (2)

jklp
jklp

Reputation: 2101

If the sound doesn't play in the simulator but does play on a live Apple TV, it might be that you've disabled user interface sounds.

To enable, load the System Preferences, select Sounds, and then tick the Play user interface sound effects checkbox (and also increase the Alert volume)

When you play the system sound, it should play in the simulator now.

Upvotes: 0

Ttrentler
Ttrentler

Reputation: 61

SO I found the Answer. . .

The above code works fine on an actual Apple TV. It does not work in the simulator. (It plays no system sounds in the Simulator.) Must be a bug.

I'm using Xcode version 7.3 and the 9.3 tvOS Simulator.

The above link to a list of sound files seems to work. I've tried 5 different systems sounds that work.

Upvotes: 1

Related Questions