internal void BeepOrVibrate() { if (!_isSilent) { SystemSound.FromFile("Sounds/beep.wav").PlayAlertSound(); } }
public static void PlaySound(string uri) { // Play the file var sound = SystemSound.FromFile(uri); sound.PlaySystemSound(); }
public void FromFile() { #if MONOMAC var path = NSBundle.MainBundle.PathForResource("1", "caf", "AudioToolbox"); #else var path = Path.GetFullPath(Path.Combine("AudioToolbox", "1.caf")); if (Runtime.Arch == Arch.SIMULATOR) { Assert.Ignore("PlaySystemSound doesn't work in the simulator"); } #endif using (var ss = SystemSound.FromFile(NSUrl.FromFilename(path))) { var completed = false; const int timeout = 10; Assert.AreEqual(AudioServicesError.None, ss.AddSystemSoundCompletion(delegate { completed = true; })); ss.PlaySystemSound(); Assert.IsTrue(MonoTouchFixtures.AppDelegate.RunAsync(DateTime.Now.AddSeconds(timeout), async() => { }, () => completed), "PlaySystemSound"); } }
public void Properties() { var path = NSBundle.MainBundle.PathForResource("1", "caf", "AudioToolbox"); using (var ss = SystemSound.FromFile(NSUrl.FromFilename(path))) { Assert.That(ss.IsUISound, Is.True, "#1"); Assert.That(ss.CompletePlaybackIfAppDies, Is.False, "#2"); } }
public void Properties() { var path = Path.GetFullPath(Path.Combine("AudioToolbox", "1.caf")); using (var ss = SystemSound.FromFile(NSUrl.FromFilename(path))) { Assert.That(ss.IsUISound, Is.True, "#1"); Assert.That(ss.CompletePlaybackIfAppDies, Is.False, "#2"); } }
public static void TriggerSoundAndViber() { try { var notificationSound = SystemSound.FromFile(NotificationSoundPath); notificationSound.AddSystemSoundCompletion(SystemSound.Vibrate.PlaySystemSound); notificationSound.PlaySystemSound(); } catch { } }
//prepares the audio public override void ViewDidLoad() { base.ViewDidLoad(); //enable audio AudioSession.Initialize(); //load the sound Sound = SystemSound.FromFile("Sounds/tap.aif"); }
public void FromFile() { var path = Path.GetFullPath(Path.Combine("AudioToolbox", "1.caf")); using (var ss = SystemSound.FromFile(NSUrl.FromFilename(path))) { Assert.AreEqual(AudioServicesError.None, ss.AddSystemSoundCompletion(delegate { })); ss.PlaySystemSound(); } }
public void DisposeTest() { var path = NSBundle.MainBundle.PathForResource("1", "caf", "AudioToolbox"); var ss = SystemSound.FromFile(NSUrl.FromFilename(path)); Assert.That(ss.Handle, Is.Not.EqualTo(IntPtr.Zero), "DisposeTest"); ss.Dispose(); // Handle prop checks NotDisposed and throws if it is Assert.Throws <ObjectDisposedException> (() => ss.Handle.ToString(), "DisposeTest"); }
public void DisposeTest() { var path = Path.GetFullPath(Path.Combine("AudioToolbox", "1.caf")); var ss = SystemSound.FromFile(NSUrl.FromFilename(path)); Assert.That(ss.Handle, Is.Not.EqualTo(IntPtr.Zero), "DisposeTest"); ss.Dispose(); // Handle prop checks NotDisposed and throws if it is Assert.Throws <ObjectDisposedException> (() => ss.Handle.ToString(), "DisposeTest"); }
public void Properties() { #if MONOMAC var path = NSBundle.MainBundle.PathForResource("1", "caf", "AudioToolbox"); #else var path = Path.GetFullPath(Path.Combine("AudioToolbox", "1.caf")); #endif using (var ss = SystemSound.FromFile(NSUrl.FromFilename(path))) { Assert.That(ss.IsUISound, Is.True, "#1"); Assert.That(ss.CompletePlaybackIfAppDies, Is.False, "#2"); } }
public void FromFile() { #if MONOMAC var path = NSBundle.MainBundle.PathForResource("1", "caf", "AudioToolbox"); #else var path = Path.GetFullPath(Path.Combine("AudioToolbox", "1.caf")); #endif using (var ss = SystemSound.FromFile(NSUrl.FromFilename(path))) { Assert.AreEqual(AudioServicesError.None, ss.AddSystemSoundCompletion(delegate { })); ss.PlaySystemSound(); } }
public void TestCallbackPlayAlert() { TestRuntime.AssertSystemVersion(PlatformName.iOS, 9, 0, throwIfOtherPlatform: false); string path = Path.Combine(NSBundle.MainBundle.ResourcePath, "drum01.mp3"); using (var ss = SystemSound.FromFile(NSUrl.FromFilename(path))) { var completed = false; const int timeout = 10; completed = false; Assert.IsTrue(MonoTouchFixtures.AppDelegate.RunAsync(DateTime.Now.AddSeconds(timeout), async() => ss.PlayAlertSound(() => { completed = true; } ), () => completed), "TestCallbackPlayAlert"); } }
public void FromFile() { TestRuntime.AssertNotSimulator(); var path = NSBundle.MainBundle.PathForResource("1", "caf", "AudioToolbox"); using (var ss = SystemSound.FromFile(NSUrl.FromFilename(path))) { var completed = false; const int timeout = 10; Assert.AreEqual(AudioServicesError.None, ss.AddSystemSoundCompletion(delegate { completed = true; })); ss.PlaySystemSound(); Assert.IsTrue(TestRuntime.RunAsync(DateTime.Now.AddSeconds(timeout), async() => { }, () => completed), "PlaySystemSound"); } }
public void TestCallbackPlaySystem() { if (!TestRuntime.CheckSystemAndSDKVersion(9, 0)) { Assert.Inconclusive("requires iOS9"); } string path = Path.Combine(NSBundle.MainBundle.ResourcePath, "drum01.mp3"); using (var ss = SystemSound.FromFile(NSUrl.FromFilename(path))) { var completed = false; const int timeout = 10; completed = false; Assert.IsTrue(MonoTouchFixtures.AppDelegate.RunAsync(DateTime.Now.AddSeconds(timeout), async() => ss.PlaySystemSound(() => { completed = true; } ), () => completed), "TestCallbackPlaySystem"); } }
public override bool StartNotifyBeep() { if (!AUDIOSESSION_INITIALIZED) { AudioSession.Initialize(); AudioSession.Category = AudioSessionCategory.MediaPlayback; AUDIOSESSION_INITIALIZED = true; } if (!AUDIOSESSION_ACTIVE) { AudioSession.SetActive(true); AUDIOSESSION_ACTIVE = true; } var sound = SystemSound.FromFile("res/SystemAlert.wav"); sound.PlayAlertSound(); return(true); }
public SoundEffect(string path) { sound = SystemSound.FromFile(new NSUrl(path, false)); }
public void Beep() { var beep = SystemSound.FromFile("beep.wav"); beep.PlaySystemSound(); }
private void BeepOrVibrate() { SystemSound.FromFile("Sounds/beep.wav").PlayAlertSound(); }
private void InitSound() { AVAudioSession.SharedInstance().SetCategory(AVAudioSessionCategory.PlayAndRecord); _sound = SystemSound.FromFile(NSUrl.FromString(NSBundle.MainBundle.PathForResource("Raws/sound_ding", "wav"))); }
public static void Play() { SystemSound sound = SystemSound.FromFile("Sounds/CrystalBell.aiff"); sound.PlayAlertSound(); }