public void ReproducirAlertaError() { if (RingTono3.IsPlaying) { RingTono3.Stop(); RingTono3.Play(); } else { RingTono3.Play(); } }
public void ReproducirAlerta() { if (RingTono2.IsPlaying) { RingTono2.Stop(); RingTono2.Play(); } else { RingTono2.Play(); } }
public async Task PlayNotificationDefaultSound() { await Task.Run(() => { // Music enabled? if (!MusicOn) { return; } if (Interlocked.Read(ref _estoySonando) != 0) { return; } Interlocked.Increment(ref _estoySonando); if (_ringtone == null) { Uri urlToNotification = RingtoneManager.GetDefaultUri(RingtoneType.Notification); _ringtone = RingtoneManager.GetRingtone(MainApplication.CurrentContext, urlToNotification); } _ringtone.Play(); Interlocked.Decrement(ref _estoySonando); }); }
public override void OnReceive(Context context, Intent intent) { Vibrator vibrator = (Vibrator)context.GetSystemService(Context.VibratorService); vibrator.Vibrate(2000); Notification notification = new Notification.Builder(context) .SetContentTitle("Будильник!!") .SetSmallIcon(Resource.Drawable.IcDialogAlert) .SetContentText("Вставай!").Build(); NotificationManager manager = (NotificationManager)context.GetSystemService(Context.NotificationService); notification.Flags = NotificationFlags.AutoCancel; manager.Notify(0, notification); Android.Net.Uri uri = RingtoneManager.GetDefaultUri(RingtoneType.Alarm); Ringtone r = RingtoneManager.GetRingtone(context, uri); r.Play(); var Page = (App)Xamarin.Forms.Application.Current; var MainPage = (MainPage)Page.MainPage; MainPage.UpdateToogles(); }
public void startRingTone() { if (mRingtonePlayer != null && mRingtonePlayer.IsPlaying) { ringRef++; return; } if (mRingtonePlayer == null && mContext != null) { try { mRingtonePlayer = RingtoneManager.GetRingtone(mContext, RingtoneManager.GetDefaultUri(RingtoneType.Ringtone)); } catch (Java.Lang.Exception e) { Console.WriteLine("startRingTone: {0} ", e.ToString()); return; } } if (mRingtonePlayer != null) { lock (mRingtonePlayer) { ringRef++; mRingtonePlayer.Play(); } } }
public void PlayNitificationTone() { Android.Net.Uri notification = RingtoneManager.GetDefaultUri(RingtoneType.Notification); Ringtone r = RingtoneManager.GetRingtone(this, notification); r.Play(); }
public void PlayExclusiveNativeSound(NativeSoundData nativeSoundData, float volume = 1.0F) { StopExclusiveNativeSound(); Android.Net.Uri uri = Android.Net.Uri.Parse((nativeSoundData.Intern ? MediaStore.Audio.Media.InternalContentUri : MediaStore.Audio.Media.ExternalContentUri).ToString() + "/" + nativeSoundData.ID); if (nativeSoundData.ID == "") { uri = Android.Net.Uri.Parse(nativeSoundData.Data); } Ringtone rt = RingtoneManager.GetRingtone(global::Android.App.Application.Context, uri); if (rt != null) { rt.AudioAttributes = new AudioAttributes.Builder() .SetUsage(AudioUsageKind.Alarm) .SetContentType(AudioContentType.Music) .Build(); rt.Looping = true; rt.Volume = volume; rt.Play(); exclusiveRingtone = rt; } }
private void TimeWalk() { long need = millSeconds; long startTime = System.DateTime.UtcNow.Ticks; while (millSeconds > 0) { lock (milSecLock) { millSeconds = need - (System.DateTime.UtcNow.Ticks - startTime - pauseTicks) / 10000; lock (refreshLock) needRefresh = true; } } running = false; pauseTicks = 0; RunOnUiThread(() => { start.Background = Resources.GetDrawable(Resource.Drawable.StartButton); clear.Background = Resources.GetDrawable(Resource.Drawable.StopButton); //SetAddMinusButtonEnable(true); start.Enabled = false; }); r.Play(); }
public override void OnReceive(Context context, Intent intent) { switch (ResultCode) { case Result.Ok: { try { Android.Net.Uri notification = RingtoneManager.GetDefaultUri(RingtoneType.Notification); Ringtone r = RingtoneManager.GetRingtone(context, notification); r.Play(); } catch (Exception e) { } Toast.MakeText(Application.Context, "SMS delivered", ToastLength.Long).Show(); break; } case Result.Canceled: { Toast.MakeText(Application.Context, "SMS not delivered", ToastLength.Long).Show(); break; } } }
public void Beep(int count) { Android.Net.Uri ringtone = RingtoneManager.GetActualDefaultRingtoneUri(Context, RingtoneType.Notification); Ringtone notification = RingtoneManager.GetRingtone(Context, ringtone); // If phone is not set to silent mode if (notification != null) { for (int i = 0; i < count; ++i) { notification.Play(); long timeout = 5000; while (notification.IsPlaying && (timeout > 0)) { timeout = timeout - 100; try { Thread.Sleep(100); } catch (InterruptedException e) { } } } } }
public void PlayAudio(bool play) { if (_Alarm == null) { var uri = RingtoneManager.GetDefaultUri(RingtoneType.Alarm); _Alarm = RingtoneManager.GetRingtone(global::Android.App.Application.Context, uri); _Timer = new System.Timers.Timer(); _Timer.Interval = 2000; _Timer.AutoReset = false; _Timer.Elapsed += _Timer_Elapsed; } if (play && !_Alarm.IsPlaying) { AccelerometerOld = null; GyroscopeMin = null; GyroscopeMax = null; OrientationMin = null; OrientationMax = null; _Alarm.Play(); _Timer.Start(); } else if (!play && _Alarm.IsPlaying) { _Alarm.Stop(); } }
private void StartSound(String audio_path) { // Play as a system sound Ringtone swingRing = RingtoneManager.GetRingtone(ApplicationContext, Android.Net.Uri.Parse(audio_path)); swingRing.AudioAttributes = new AudioAttributes.Builder().SetFlags(AudioFlags.None).SetLegacyStreamType(Android.Media.Stream.System).Build(); swingRing.Play(); }
private void btnAlarm_On_Click(object sender, EventArgs e) { Toast.MakeText(this, $"Alarm sounding ...", ToastLength.Short).Show(); ringer.Play(); //Thread.Sleep(10000); //ringer.Stop(); }
public override void OnFinish() { inputField.Text = "0:00"; Android.Net.Uri notificationUri = RingtoneManager.GetDefaultUri(RingtoneType.Notification); Ringtone tone = RingtoneManager.GetRingtone(context, notificationUri); tone.Play(); }
public void Play() { //TODO: Implement some form of enum. var notification = RingtoneManager.GetDefaultUri(RingtoneType.Notification); Ringtone r = RingtoneManager.GetRingtone(CurrentActivity, notification); r.Play(); }
public static void Play() { try { Android.Net.Uri notification = RingtoneManager.GetDefaultUri(RingtoneType.Notification); Ringtone r = RingtoneManager.GetRingtone(Application.Context, notification); r.Play(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
private void BtnAlarm_Click(object sender, System.EventArgs e) { try { Android.Net.Uri alarm = RingtoneManager.GetDefaultUri(RingtoneType.Alarm); Ringtone r = RingtoneManager.GetRingtone(this, alarm); r.Play(); } catch (Exception ex) { Toast.MakeText(this, ex.Message, ToastLength.Long).Show(); } }
public void SetNotificationSound() { try { Uri defaultSoundUri = Uri.Parse("android.resource://" + Android.App.Application.Context.PackageName + "/" + Resource.Raw.notifysound); Ringtone r = RingtoneManager.GetRingtone(Android.App.Application.Context, defaultSoundUri); r.Play(); } catch (System.Exception e) { } }
private void DeclareSwitchEvents() { Switch swTabNDOptionsVibration = FindViewById <Switch>(Resource.Id.swTabNDOptionsVibration); swTabNDOptionsVibration.CheckedChange += delegate(object sender, CompoundButton.CheckedChangeEventArgs e) { bool boolchecked = e.IsChecked; // Store Global Value prefs = PreferenceManager.GetDefaultSharedPreferences(this); ISharedPreferencesEditor editor = prefs.Edit(); if (boolchecked) { Vibrator v = (Vibrator)this.GetSystemService(Context.VibratorService); // Make phone vibrate v.Vibrate(1000); editor.PutInt("AlertVibrate", 1); } else { editor.PutInt("AlertVibrate", 0); } editor.Commit(); editor.Apply(); }; Switch swTabNDOptionsAlert = FindViewById <Switch>(Resource.Id.swTabNDOptionsAlert); swTabNDOptionsAlert.CheckedChange += delegate(object sender, CompoundButton.CheckedChangeEventArgs e) { bool boolchecked = e.IsChecked; // Store Global Value prefs = PreferenceManager.GetDefaultSharedPreferences(this); ISharedPreferencesEditor editor = prefs.Edit(); if (boolchecked) { Android.Net.Uri notification = RingtoneManager.GetDefaultUri(RingtoneType.Notification); Ringtone r = RingtoneManager.GetRingtone(this, notification); r.Play(); editor.PutInt("AlertTone", 1); } else { editor.PutInt("AlertTone", 0); } editor.Commit(); editor.Apply(); }; }
public void Play() { var volume = audiomanager.GetStreamVolume(Stream.Ring); if (volume > 0) { ringTone.Play(); } else { vibrator.Vibrate(1000 * 3); } }
public void PlaySystemSound() { //If the ringer mode is different than "Normal" (2), enables the normal mode. AudioManager am = (AudioManager)Application.Context.GetSystemService(Context.AudioService); if (!am.RingerMode.Equals(2)) { am.RingerMode = RingerMode.Normal; //am.SetVibrateSetting(VibrateType.Ringer, VibrateSetting.On); } Android.Net.Uri uri = RingtoneManager.GetDefaultUri(RingtoneType.Ringtone); rt = RingtoneManager.GetRingtone(MainActivity.instance.ApplicationContext, uri); rt.Play(); }
public override void OnReceive(Context context, Intent intent) { Toast.MakeText(context, "Running", ToastLength.Short).Show(); System.Diagnostics.Debug.WriteLine("Running..."); try { Uri notification = RingtoneManager.GetDefaultUri(RingtoneType.Notification); Ringtone tone = RingtoneManager.GetRingtone(Application.Context, notification); tone.Play(); } catch (Error e) { System.Diagnostics.Debug.WriteLine(e.Message); } }
/// <summary> /// spielt den Ton mit der URI ab /// </summary> /// <param name="uri"></param> /// <param name="volume">0.0 .. 1.0</param> static void playNotifyRingtone(Android.Net.Uri uri, float volume = 1.0F) { stopNotifyRingtone(); Ringtone rt = RingtoneManager.GetRingtone(appcontext, uri); if (rt != null) { rt.AudioAttributes = new AudioAttributes.Builder() .SetUsage(AudioUsageKind.Alarm) .SetContentType(AudioContentType.Music) .Build(); rt.Looping = false; rt.Volume = volume; rt.Play(); alarmRingtone = rt; } }
public static void playAlarm() { try { var n = RingtoneManager.GetDefaultUri(RingtoneType.Notification); var last_ = getContextLast(); if (last_ != null) { Ringtone r = RingtoneManager.GetRingtone(last_, n); r.Play(); } } catch (Exception e) { setExceptionInner(e); } }
public void Notifications() { try { var currentContext = Android.App.Application.Context; var alarmUri = RingtoneManager.GetDefaultUri(RingtoneType.Alarm); Ringtone = RingtoneManager.GetRingtone(currentContext.ApplicationContext, alarmUri); Ringtone.Play(); long[] pattern = { 0, 1500, 2000 }; Vibrator = Vibrator.FromContext(currentContext); Vibrator.Vibrate(pattern, 0); } catch (Exception ex) { UserDialogs.Instance.Alert("Bład!\r\n\r\n" + ex.ToString(), "Błąd", "OK"); } }
public void PlayAlarm(bool fromMummy = false) { if (IsAlarmGoingOf == false) { if (fromMummy) { ClearAlarm(); } var launchIntent = context.PackageManager.GetLaunchIntentForPackage(context.PackageName); launchIntent.SetFlags(ActivityFlags.ReorderToFront | ActivityFlags.NewTask | ActivityFlags.ResetTaskIfNeeded); context.StartActivity(launchIntent); _ringtone.Play(); EventController.RaiseAlarmIsRinging(this, fromMummy); } IsAlarmGoingOf = true; }
private void Btn3_Click(object sender, EventArgs e) { Log.Info(TAG, "btn3 was clicked!"); //using (r = RingtoneManager.GetRingtone(this, RingtoneManager.GetDefaultUri(RingtoneType.Ringtone))) //{ r.Play(); } if (r != null && r.IsPlaying) { r.Stop(); } //r = RingtoneManager.GetRingtone(this, RingtoneManager.GetDefaultUri(RingtoneType.Ringtone)); Android.Net.Uri uri = RingtoneManager.GetDefaultUri(RingtoneType.Ringtone); r = RingtoneManager.GetRingtone(this, uri); r.Play(); Console.WriteLine("+++++ default ring attributes ==================== " + r.AudioAttributes); Console.WriteLine("+++++ default ring URI ==================== " + uri.Path); }
public void Initialize() { _notificationsStream .DistinctUntilChanged() .Subscribe(ntf => { if (ntf) { _alertRingtonne.Play(); } }); _subscription = DtoStream.Subscribe(dto => { VM.Distance = dto.Ave; // forward notifications flag to next stream _notificationsStream.OnNext(dto.Gone == 0 ? false : true); VM.Status = dto.Prx.ToString(); switch (dto.Prx) { case ProximityState.Measuring: VM.Color = Color.FromRgb(45, 214, 236); break; case ProximityState.Alert: VM.Color = Color.FromRgb(244, 150, 138); break; case ProximityState.Warning: VM.Color = Color.FromRgb(254, 215, 151); break; case ProximityState.Safe: VM.Color = Color.FromRgb(132, 224, 168); break; } }); }
public void PlayRingtone(string uri) { RingtoneManager ringtoneManager = new RingtoneManager(context); Android.Net.Uri _uri = Android.Net.Uri.Parse(uri); AudioManager audioManager = (AudioManager)context.GetSystemService(Context.AudioService); audioManager.SetStreamVolume(Stream.Alarm, audioManager.GetStreamMaxVolume(Stream.Alarm), 0); if (ringtone != null) { if (ringtone.IsPlaying) { ringtone.Stop(); } } ringtone = ringtoneManager.GetRingtone(ringtoneManager.GetRingtonePosition(_uri)); ringtone.StreamType = Stream.Alarm; ringtone.Play(); }
/// <inheritdoc /> public void Play() => mSound.Play();