Esempio n. 1
0
        public static void StartPlayer(Context context, AlarmAction action, int duration, float volume)
        {
            if (player != null)
            {
                StopPlayer();
            }

            player         = MediaPlayer.Create(context, action.ResourceID);
            player.Looping = true;
            player.SetVolume(volume, volume);
            timer          = new Timer(duration * 1000);
            timer.Elapsed += Timer_Elapsed;
            player.Start();
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            RequestWindowFeature(WindowFeatures.NoTitle);
            SetContentView(Resource.Layout.AlarmGoingOff);
            alarmOff    = FindViewById <Button>(Resource.Id.alarmgoingoff_off);
            alarmSnooze = FindViewById <Button> (Resource.Id.alarmgoingoff_snooze);
            alarmTime   = FindViewById <TextView> (Resource.Id.alarmgoingoff_time);

            alarmOff.Click    += AlarmOff_Click;
            alarmSnooze.Click += AlarmSnooze_Click;

            alarm = (Alarm)this.Intent.GetParcelableExtra("startAlarm");
            string time = string.Format("{0}.{1}", alarm.Time.Hours.ToString(), alarm.Time.Minutes.ToString().PadLeft(2, '0'));

            alarmTime.Text = time;
            AlarmAction action = ActionMngr.Actions[alarm.ActionID];

            ActionMngr.StartPlayer(this, action, alarm.Duration, alarm.Volume);
        }