Exemplo n.º 1
0
        private void Page_Unloaded(object sender, RoutedEventArgs e)
        {
            var playQueue = PlayQueueManager.GetInstance();

            playQueue.TrackChanged   -= PlayQueue_TrackChanged;
            playQueue.CurrentChanged -= PlayQueue_CurrentChanged;
        }
Exemplo n.º 2
0
        private void TrackButton_Click(object sender, RoutedEventArgs e)
        {
            var index = ItemsControlHelper.FindIndexByItemChild(panelTracks, sender as DependencyObject);

            if (index == -1)
            {
                return;
            }

            var playQueue = PlayQueueManager.GetInstance();
            var track     = playQueue.FromTracks(Tracks.ToArray(), index);

            playQueue.AddPlayedIndex();

            var playback = PlaybackManager.GetInstance();

            playback.Play(track);

            var app = (App)Application.Current;

            app.config.LastPlaylist = Playlist.MetadataUrl;

            var mainWindow = MainWindow.GetInstance();

            mainWindow.GoToPlayQueue();
        }
Exemplo n.º 3
0
        private void AddToPlayQueue_Click(object sender, RoutedEventArgs e)
        {
            var track = (PlexTrack)((MenuItem)e.Source).DataContext;

            var playQueue = PlayQueueManager.GetInstance();

            playQueue.Add(track);

            var mainWindow = MainWindow.GetInstance();

            mainWindow.FlashPlayQueue();
        }
Exemplo n.º 4
0
        private void TrackButton_DeleteClick(object sender, RoutedEventArgs e)
        {
            var index = ItemsControlHelper.FindIndexByItemChild(panelTracks, sender as DependencyObject);

            if (index == -1)
            {
                return;
            }

            var playQueue = PlayQueueManager.GetInstance();

            playQueue.Remove(index);
        }
Exemplo n.º 5
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
            {
                return;
            }

            var playQueue = PlayQueueManager.GetInstance();

            playQueue.TrackChanged   += PlayQueue_TrackChanged;
            playQueue.CurrentChanged += PlayQueue_CurrentChanged;

            PlayQueue_TrackChanged(this, e);
            PlayQueue_CurrentChanged(this, e);
        }
Exemplo n.º 6
0
        void IDropTarget.Drop(IDropInfo dropInfo)
        {
            var source    = (Component.TrackButton)VisualTreeHelper.GetChild(dropInfo.DragInfo.VisualSourceItem, 0);
            int sourceIdx = ItemsControlHelper.FindIndexByItemChild(panelTracks, source);
            int targetIdx = dropInfo.InsertIndex;

            if (sourceIdx == targetIdx || sourceIdx == -1 || targetIdx == -1)
            {
                return;
            }

            var playQueue = PlayQueueManager.GetInstance();

            playQueue.Rearrange(sourceIdx, targetIdx);
        }
Exemplo n.º 7
0
        private void MenuItem_Play_Click(object sender, RoutedEventArgs e)
        {
            var button = (Component.TrackButton)((ContextMenu)((MenuItem)e.Source).Parent).PlacementTarget;
            var index  = ItemsControlHelper.FindIndexByItemChild(panelTracks, button);

            var playQueue = PlayQueueManager.GetInstance();
            var track     = playQueue.FromTracks(Tracks, index);

            playQueue.AddPlayedIndex();

            var playback = PlaybackManager.GetInstance();

            playback.Play(track);

            var mainWindow = MainWindow.GetInstance();

            mainWindow.GoToPlayQueue();
        }
Exemplo n.º 8
0
        private void TrackButton_Click(object sender, RoutedEventArgs e)
        {
            var button = (Component.TrackButton)sender;

            var index = ItemsControlHelper.FindIndexByItemChild(panelTracks, button);

            if (index == -1)
            {
                return;
            }

            skipNextCurrentChanged = true;

            var playQueue = PlayQueueManager.GetInstance();

            playQueue.Play(index);

            var playback = PlaybackManager.GetInstance();

            playback.Play(button.Track);
        }
Exemplo n.º 9
0
        private async void HandlePlayQueueTrackChanged(PlayQueueManager sender, TrackInfo args)
        {
            int newRowId = 0;

            Logger.Current.Log(new CallerInfo(), LogLevel.Info, "Track changed, args set? {0}", args != null);

            if (args != null)
            {
                systemMediaTransportControls.PlaybackStatus = MediaPlaybackStatus.Playing;

                systemMediaTransportControls.DisplayUpdater.Type = MediaPlaybackType.Music;
                systemMediaTransportControls.DisplayUpdater.MusicProperties.Title       = args.Title;
                systemMediaTransportControls.DisplayUpdater.MusicProperties.Artist      = args.Artist;
                systemMediaTransportControls.DisplayUpdater.MusicProperties.AlbumArtist = args.AlbumArtist;

                systemMediaTransportControls.IsNextEnabled     = (args.NextId > 0);
                systemMediaTransportControls.IsPreviousEnabled = (args.PrevId > 0);

                newRowId = args.RowId;
            }
            else
            {
                systemMediaTransportControls.PlaybackStatus = MediaPlaybackStatus.Stopped;
            }

            if (foregroundTaskState == ForegroundTaskState.Running)
            {
                Logger.Current.Log(new CallerInfo(), LogLevel.Info, "Alerting FG of track change {0}", newRowId);

                PlayQueueManager.Current.SendMessageToForeground(PlayQueueConstantBGMessageId.TrackChanged, newRowId);
            }

            systemMediaTransportControls.DisplayUpdater.Update();

            await UpdateTile(args);
        }
Exemplo n.º 10
0
        private void PlayQueue_CurrentChanged(object sender, EventArgs e)
        {
            if (skipNextCurrentChanged)
            {
                skipNextCurrentChanged = false;
                return;
            }

            var app = (App)Application.Current;

            // scroll to current playing offset
            Task.Factory.StartNew(() =>
            {
                var playQueue = PlayQueueManager.GetInstance();

                if (playQueue.Current < 0)
                {
                    return;
                }

                var scrollViewer = (ScrollViewer)VisualTreeHelper.GetChild(panelTracks, 0);
                scrollViewer.ScrollToVerticalOffset(playQueue.Current - 1);
            }, CancellationToken.None, TaskCreationOptions.None, app.uiContext);
        }
Exemplo n.º 11
0
        private void PlayQueue_TrackChanged(object sender, EventArgs e)
        {
            var playQueue = PlayQueueManager.GetInstance();

            Tracks.FromArray(playQueue.GetArray());
        }