문제

I am trying to stop playing a sound when the screen is touched. Currently the sound is being played with

AudioToolbox.SystemSound.FromFile("sound.mp3").PlaySystemSound();

I have a UIEvent in another class that fires on all touches. I want to add the functionality to stop playing the audio to this event, however I'm unable to figure out how to do so.

From searching online, I've seen people being recommended to use AVAudioPlayer instead of AudioToolbox, but I'm not able to find how to stop the audio playing using AudioToolbox either.

도움이 되었습니까?

해결책

Try to destroy instance:

// start playing
var sound = AudioToolbox.SystemSound.FromFile("sound.mp3");
sound.PlaySystemSound();

// Stop playing
sound.Close (); // Alternatively, try to sound.Dispose ();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top