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");
            }
        }
        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));
 }
        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();
        }