Exemple #1
0
        private async void DeaktivateSystemMediaTransportControlButtons()
        {
            FolderMusicUwpLib.SaveTextClass.SaveText("WaitStart");

            deactivateSMTC++;
            await Task.Delay(TimeSpan.FromSeconds(289));

            if (BackgroundMediaPlayer.Current.CurrentState == MediaPlayerState.Playing ||
                --deactivateSMTC > 0 || systemMediaTransportControl.IsEnabled == false)
            {
                return;
            }

            FolderMusicUwpLib.SaveTextClass.SaveText("BeforeQuestion");

            gotReplayFromForeground = false;
            ForegroundCommunicator.SendIsActiv();
            await Task.Delay(1000);

            if (gotReplayFromForeground)
            {
                return;
            }

            FolderMusicUwpLib.SaveTextClass.SaveText("Deactivate");

            systemMediaTransportControl.IsPreviousEnabled = systemMediaTransportControl.IsNextEnabled =
                //systemMediaTransportControl.IsRewindEnabled = systemMediaTransportControl.IsFastForwardEnabled =
                systemMediaTransportControl.IsPauseEnabled = false;
        }
Exemple #2
0
        private async Task LoadLibraryData()
        {
            await Library.Current.LoadAsync();

            SetLoopToBackgroundPlayer();

            ForegroundCommunicator.SendXmlText();
            //SaveText("Load");
        }
Exemple #3
0
        public void Pause()
        {
            if (BackgroundMediaPlayer.Current.CurrentState != MediaPlayerState.Paused)
            {
                Volume1To0AndPause();
            }

            autoPlay = false;
            systemMediaTransportControl.PlaybackStatus = MediaPlaybackStatus.Paused;

            ForegroundCommunicator.SendPause();

            DeaktivateSystemMediaTransportControlButtons();
            LibraryLib.CurrentSong.Current.Save();
        }
Exemple #4
0
        private async void BackgroundMediaPlayer_MediaOpened(MediaPlayer sender, object args)
        {
            FolderMusicUwpLib.SaveTextClass.SaveText("Open", CurrentSong.Title);

            openSong        = CurrentSong;
            sender.Position = TimeSpan.FromMilliseconds(CurrentSongPositionTotalMilliseconds);

            if (autoPlay)
            {
                if (sender.Position.TotalMilliseconds == 1)
                {
                    sender.Volume = 1;
                    sender.Play();
                }
                else
                {
                    Play();
                }
            }
            else
            {
                systemMediaTransportControl.PlaybackStatus = MediaPlaybackStatus.Paused;
            }

            playNext = true;

            if (CurrentSong.NaturalDurationMilliseconds == 1)
            {
                CurrentSong.NaturalDurationMilliseconds = sender.NaturalDuration.TotalMilliseconds;
            }

            UpdateSystemMediaTransportControl();

            /*
             * if (!Library.IsLoaded) await LoadLibraryData();
             * else                //      */
            {
                ForegroundCommunicator.SendSongsIndexAndShuffleIfComplete();
            }

            await LibraryLib.CurrentSong.Current.Save();
        }
Exemple #5
0
        public void Run(IBackgroundTaskInstance taskInstance)
        {
            FolderMusicUwpLib.SaveTextClass.SetId(taskInstance.InstanceId.ToString());
            FolderMusicUwpLib.SaveTextClass.SaveText("Run");

            task = this;

            lastTicks = DateTime.Now.Ticks;

            ForegroundCommunicator.SetReceivedEvent();

            systemMediaTransportControl = SystemMediaTransportControls.GetForCurrentView();
            deferral = taskInstance.GetDeferral();

            ActivateSystemMediaTransportControl();
            systemMediaTransportControl.ButtonPressed += MediaTransportControlButtonPressed;

            SetEvents(taskInstance);

            LoadCurrentSongAndLibrary();
        }
Exemple #6
0
        private async void SkipSong(Song song)
        {
            await SkipSongs.AddSkipSongAndSave(song);

            ForegroundCommunicator.SendSkip();
        }