Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to cancel a playing sound started with AudioServicesPlaySystemSound?

Is there a way to cancel, pause or stop a sound that started playing through a call to AudioServicesPlaySystemSound()?

like image 812
openfrog Avatar asked Dec 22 '12 11:12

openfrog


1 Answers

Unfortunately you can't - like the name suggests, it's designed for playing sounds to be used for system alerts, where you don't need to have control over them. You can stop a sound played through AudioServicesPlaySystemSound() by calling AudioServicesDisposeSystemSoundID(), but this is a hacky and best avoided.

The best option for straightforward, simple control of audio playback is to use AVPlayer, part of AVFoundation - documentation here.

like image 173
lxt Avatar answered Oct 20 '22 14:10

lxt