private async Task setNextBibleChapter(AlarmSchedule schedule, bool switchingPublication = false) { if (switchingPublication) { schedule.CurrentPlayItem = PlayType.Bible; await scheduleService.Update(schedule); return; } var bible = schedule.Bible as BibleAudio; var chapters = await mediaService.GetBibleChapters(bible.LanguageCode, bible.VersionCode, bible.BookNumber); if (bible.ChapterNumber < chapters.Count) { bible.ChapterNumber++; await scheduleService.Update(schedule); return; } var books = await mediaService.GetBibleBooks(bible.LanguageCode, bible.VersionCode); var nextBook = books.NextHigher(bible.BookNumber); bible.BookNumber = nextBook.Key; await scheduleService.Update(schedule); return; }
private void createNotification(AlarmSchedule schedule) { var notifier = ToastNotificationManager.CreateToastNotifier(); var scheduledNotification = generateAlarmNotification(schedule, schedule.NextFireDate()); notifier.AddToSchedule(scheduledNotification); }
public virtual async Task Update(AlarmSchedule schedule) { await getSchedules(); schedules[schedule.Id] = schedule; await saveChanges(); }
public virtual async Task Create(AlarmSchedule schedule) { await getSchedules(); schedule.Id = getNextId(); schedules.Add(schedule.Id, schedule); await saveChanges(); }
private async Task <PlayItem> nextBibleUrlToPlay(AlarmSchedule schedule) { var bibleAudio = schedule.Bible; var bibleTracks = await mediaService.GetBibleChapters(bibleAudio.LanguageCode, bibleAudio.VersionCode, bibleAudio.BookNumber); var bibleTrack = bibleTracks[bibleAudio.ChapterNumber]; return(new PlayItem(bibleTrack.Url, bibleAudio.Second)); }
public override async Task Update(AlarmSchedule schedule) { removeNotification(schedule.Id.ToString()); if (schedule.IsEnabled) { createNotification(schedule); } await base.Update(schedule); }
public override async Task Stop(AlarmSchedule schedule) { var mediaPlayer = alarmToMediaPlayersMap[schedule.Id]; var second = mediaPlayer.PlaybackSession.Position.TotalSeconds; await UpdatePlayedSeconds(schedule, (int)second < 0? 0 : (int)second); mediaPlayer.Dispose(); await base.Stop(schedule); }
public ScheduleViewModel(AlarmSchedule model = null) { this.scheduleService = IocSetup.Container.Resolve <IScheduleService>(); this.popUpService = IocSetup.Container.Resolve <IPopUpService>(); isNewSchedule = model == null ? true : false; Model = model ?? new AlarmSchedule(); EnableCommand = new RelayCommandAsync <object>(async(x) => { IsEnabled = bool.Parse(x.ToString()); await SaveAsync(); }); }
public async Task UpdatePlayedSeconds(AlarmSchedule schedule, int second) { switch (schedule.CurrentPlayItem) { case PlayType.Music: break; case PlayType.Bible: (schedule.Bible as BibleAudio).Second = second; await scheduleService.Update(schedule); break; } }
private static ScheduledToastNotification generateAlarmNotification(AlarmSchedule alarm, DateTimeOffset alarmTime) { var content = new ToastContent() { Scenario = ToastScenario.Reminder, DisplayTimestamp = alarmTime, Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = "Alarm", HintMaxLines = 1 }, new AdaptiveText() { Text = alarm.Name } } } }, Actions = new ToastActionsSnoozeAndDismiss() }; // We can easily enable Universal Dismiss by generating a RemoteId for the alarm that will be // the same on both devices. We'll just use the alarm delivery time. If an alarm on one device // has the same delivery time as an alarm on another device, it'll be dismissed when one of the // alarms is dismissed. string remoteId = (alarmTime.Ticks / 10000000 / 60).ToString(); // Minutes return(new ScheduledToastNotification(content.GetXml(), alarmTime) { Group = "alarms", Tag = alarm.Id.ToString(), RemoteId = remoteId }); }
private async Task <PlayItem> nextMusicUrlToPlay(AlarmSchedule schedule) { switch (schedule.Music.MusicType) { case MusicType.Melodies: var melodyMusic = schedule.Music as MelodyMusic; var melodyTracks = await mediaService.GetMelodyMusicTracks(melodyMusic.VersionCode, melodyMusic.DiscCode); var melodyTrack = melodyTracks[melodyMusic.TrackNumber]; return(new PlayItem(melodyTrack.Url, 0)); case MusicType.Vocals: var vocalMusic = schedule.Music as VocalMusic; var vocalTracks = await mediaService.GetVocalMusicTracks(vocalMusic.LanguageCode, vocalMusic.VersionCode, vocalMusic.DiscCode); var vocalTrack = vocalTracks[vocalMusic.TrackNumber]; return(new PlayItem(vocalTrack.Url, 0)); } return(null); }
public override async Task Create(AlarmSchedule schedule) { createNotification(schedule); await base.Create(schedule); }
public async virtual Task Stop(AlarmSchedule schedule) { await scheduleService.Update(schedule); }