private static void Subscribe(BackgroundAudioTask task) { string smtcType = task?.smtc.DisplayUpdater.Type.ToString() ?? "null"; string smtcHash = task?.smtc.DisplayUpdater.GetHashCode().ToString() ?? "null"; MobileDebug.Service.WriteEventPair("BackSubscribe", "SmtcType", smtcType, "SmtcHash", smtcHash); if (task == null) { return; } if (task.smtc != null) { task.smtc.ButtonPressed += task.MediaTransportControlButtonPressed; } BackgroundMediaPlayer.Current.CurrentStateChanged += task.BackgroundMediaPlayer_CurrentStateChanged; BackgroundMediaPlayer.Current.MediaEnded += task.BackgroundMediaPlayer_MediaEnded; BackgroundMediaPlayer.Current.MediaOpened += task.BackgroundMediaPlayer_MediaOpened; BackgroundMediaPlayer.Current.MediaFailed += task.BackgroundMediaPlayer_MediaFailed; task.lsh.IsPlayingChanged += task.OnPlayStateChanged; task.lsh.CurrentPlaylistChanged += task.OnCurrentPlaylistChanged; task.lsh.SettingsChanged += task.OnSettingsChanged; task.lsh.CurrentPlaylist.CurrentSongChanged += task.OnCurrentSongChanged; task.lsh.CurrentPlaylist.LoopChanged += task.OnLoopChanged; }
public async void Run(IBackgroundTaskInstance taskInstance) { string taskId = taskInstance.InstanceId.ToString(); MobileDebug.Service.SetIsBackground(taskId); MobileDebug.Service.WriteEventPair("Run", "task == null", task == null, "this.Hash", GetHashCode(), "PlayerHash", BackgroundMediaPlayer.Current.GetHashCode()); deferral = taskInstance.GetDeferral(); taskInstance.Canceled += OnCanceled; taskInstance.Task.Completed += TaskCompleted; Unsubscribe(task); saveLoad = new AutoSaveLoad(completeFileName, backupFileName, simpleFileName); library = await saveLoad.LoadSimple(false); lsh = LibrarySubscriptionsHandler.GetInstance(library); smtc = SystemMediaTransportControls.GetForCurrentView(); task = this; musicPlayer = new MusicPlayer(smtc, library); ringer = new Ringer(this, library); await saveLoad.LoadComplete(library); saveLoad.Add(library); Subscribe(task); await BackgroundPlayer.SetCurrent(); MobileDebug.Service.WriteEventPair("RunFinish", "This", GetHashCode(), "Lib", library.GetHashCode()); }
public Ringer(BackgroundAudioTask backgroundAudioTask, ILibrary library) { task = backgroundAudioTask; this.library = library; timer = new Timer(Ring, null, Timeout.Infinite, Timeout.Infinite); ReloadTimes(); }