internal void BeepOrVibrate()
 {
     if (!_isSilent)
     {
         SystemSound.FromFile("Sounds/beep.wav").PlayAlertSound();
     }
 }
Пример #2
0
        public static void PlaySound(string uri)
        {
            // Play the file
            var sound = SystemSound.FromFile(uri);

            sound.PlaySystemSound();
        }
Пример #3
0
        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");
            }
        }
Пример #4
0
        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");
            }
        }
Пример #5
0
        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");
            }
        }
Пример #6
0
 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");
        }
Пример #8
0
        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();
            }
        }
Пример #9
0
        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");
        }
Пример #10
0
        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");
        }
Пример #11
0
        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");
            }
        }
Пример #12
0
        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();
            }
        }
Пример #13
0
        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");
            }
        }
Пример #14
0
        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");
            }
        }
Пример #15
0
        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");
            }
        }
Пример #16
0
        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);
        }
Пример #17
0
 public SoundEffect(string path)
 {
     sound = SystemSound.FromFile(new NSUrl(path, false));
 }
Пример #18
0
        public void Beep()
        {
            var beep = SystemSound.FromFile("beep.wav");

            beep.PlaySystemSound();
        }
Пример #19
0
 private void BeepOrVibrate()
 {
     SystemSound.FromFile("Sounds/beep.wav").PlayAlertSound();
 }
Пример #20
0
 private void InitSound()
 {
     AVAudioSession.SharedInstance().SetCategory(AVAudioSessionCategory.PlayAndRecord);
     _sound = SystemSound.FromFile(NSUrl.FromString(NSBundle.MainBundle.PathForResource("Raws/sound_ding", "wav")));
 }
Пример #21
0
        public static void Play()
        {
            SystemSound sound = SystemSound.FromFile("Sounds/CrystalBell.aiff");

            sound.PlayAlertSound();
        }