Ejemplo n.º 1
0
        private void MediaPlaybackListOnCurrentItemChanged(MediaPlaybackList sender,
                                                           CurrentMediaPlaybackItemChangedEventArgs args)
        {
            // Get the new item
            var item = args.NewItem;

            // Get the current track
            var currentTrack = item?.Source?.Queue();

            // Update the system view
            _smtcWrapper.UpdateUvcOnNewTrack(currentTrack?.Track);

            if (currentTrack != null)
            {
                Debug.WriteLine("PlaybackList_CurrentItemChanged: " + currentTrack.Id);

                // Notify foreground of change or persist for later
                if (ForegroundAppState == AppState.Active)
                {
                    MessageHelper.SendMessageToForeground(new TrackChangedMessage(currentTrack.Id));
                }

                _settingsUtility.Write(ApplicationSettingsConstants.QueueId, currentTrack.Id);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Raised when playlist changes to a new track
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        void PlaybackList_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            // Get the new item
            var item = args.NewItem;

            Debug.WriteLine("PlaybackList_CurrentItemChanged: " + (item == null ? "null" : GetTrackId(item).ToString()));

            // Update the system view
            UpdateUVCOnNewTrack(item);

            // Get the current track
            Uri currentTrackId = null;

            if (item != null)
            {
                currentTrackId = item.Source.CustomProperties[TrackIdKey] as Uri;
            }

            // Notify foreground of change or persist for later
            if (foregroundAppState == AppState.Active)
            {
                MessageService.SendMessageToForeground(new TrackChangedMessage(currentTrackId));
            }
            else
            {
                ApplicationSettingsHelper.SaveSettingsValue(TrackIdKey, currentTrackId == null ? null : currentTrackId.ToString());
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Method which is executen on change of currently played item
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="arguments"></param>
        private void PlaylistItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs arguments)
        {
            try
            {
                if (currentItem != null)
                {
                    if (arguments.NewItem != currentItem.PlaybackItem)
                    {
                        var newItem = arguments.NewItem;
                        currentItem = currentPlaylist.musicFileList
                                      .Where(m => m.PlaybackItem == newItem).Single();

                        // Update the system view
                        UpdateTrackViewInfo(newItem);
                        //Send change of currently played item to foreground
                        SendCurrentItemToForeground();
                    }
                }
                else
                {
                    var newItem = arguments.NewItem;
                    currentItem = currentPlaylist.musicFileList
                                  .Where(m => m.PlaybackItem == newItem).Single();

                    // Update the system view
                    UpdateTrackViewInfo(newItem);
                    //Send change of currently played item to foreground
                    SendCurrentItemToForeground();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// This call comes in on a worker thread so requires a little extra care
        /// to avoid touching the UI if it has already been disposed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private async void PlaybackList_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            // If the event was unsubscribed before
            // this handler executed just return.
            if (disposed)
            {
                return;
            }

            await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                // If the event was unsubscribed before
                // this handler executed just return.
                if (disposed)
                {
                    return;
                }

                var playbackItem = args.NewItem;

                if (playbackItem == null)
                {
                    CurrentItem = null;
                }
                else
                {
                    // Find the single item in this list with a playback item
                    // matching the one we just received the event for.
                    CurrentItem = this.Single(mediaItemViewModel => mediaItemViewModel.PlaybackItem == playbackItem);
                }
            });
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     Called when the current playing item changes
        /// </summary>
        private async void CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            await DispatcherHelper.ExecuteOnUIThreadAsync(async() =>
            {
                // Only perform the following actions if there is a new track
                if (args.NewItem == null)
                {
                    return;
                }

                if (Service.CurrentTrack == null)
                {
                    return;
                }

                // Set the pin button text
                PinButtonText = TileService.Instance.DoesTileExist("Track_" + Service.CurrentTrack.Id) ? "Unpin" : "Pin";

                // Set the like button text
                LikeButtonText = await SoundByteService.Instance.ExistsAsync("/me/favorites/" + Service.CurrentTrack.Id)
                    ? "Unlike"
                    : "Like";

                // Set the repost button text
                RepostButtonText =
                    await SoundByteService.Instance.ExistsAsync("/e1/me/track_reposts/" + Service.CurrentTrack.Id)
                        ? "Unpost"
                        : "Repost";

                // Reload all the comments
                CommentItems.RefreshItems();
            });
        }
 private void MusicPlaybackList_CurrentItemChanged(object sender, CurrentMediaPlaybackItemChangedEventArgs e)
 {
     if (sender is MediaPlaybackList playlist)
     {
         ViewModel.ChangeMusicSelection((int)playlist.CurrentItemIndex);
     }
 }
 /// <summary>
 /// 同步正在播放的项目到UI界面
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 private void PlaybackList_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
 {
     var task = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         playlistView.SelectedIndex = (int)sender.CurrentItemIndex;
     });
 }
Ejemplo n.º 8
0
        private void OnCurrentItemChangedAsync(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            var newItem = args.NewItem;

            if (newItem == null)
            {
                return;
            }
            ChangeSelectItem();
            if (newItem.Source.CustomProperties["Message"] is MusicBoardParameter para)
            {
                AppResources.MusicIsCurrent = para;
            }
            if (ServiceType == MusicServiceType.MHz)
            {
                ActionForMHz?.Invoke();
            }
            CacheItems.Add(newItem);
            if (CacheItems.Count <= CacheMax || CacheItems.ToList().Exists(i => i.Source.CustomProperties["SHA256"] as string == newItem.Source.CustomProperties["SHA256"] as string))
            {
                return;
            }
            CacheItems[0].Source.Reset();
            CacheItems.RemoveAt(0);
        }
Ejemplo n.º 9
0
        private void OnCurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            if (args.NewItem == null)
            {
                //Execute.BeginOnUIThread(() => CurrentItem = null);
                //Dispose();

                //Debug.WriteLine("PlaybackService: Playback completed");
            }
            else if (_mapping.TryGetValue(args.NewItem, out TLMessage message))
            {
                Execute.BeginOnUIThread(() => CurrentItem = message);
                Debug.WriteLine("PlaybackService: Playing message " + message.Id);

                MarkAsRead(message);
            }
            else
            {
                Execute.BeginOnUIThread(() => CurrentItem = null);
                Debug.WriteLine("PlaybackService: Current item changed, can't find related message");
            }

            if (_queue != null && _queue.Count > 0)
            {
                Enqueue(_queue.Dequeue(), false);
            }
        }
Ejemplo n.º 10
0
        private async void PlayList_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            var playbackItem = args.NewItem;

            await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => this.CurrentMediaPlaybackItem = playbackItem);


            if (playbackItem != null)
            {
                await SetCurrentSong(playbackItem.GetDisplayProperties());
            }
            else
            {
                await SetCurrentSong(null);
            }

            async Task SetCurrentSong(MediaItemDisplayProperties displayPropertys)
            {
                if (this.Dispatcher.HasThreadAccess)
                {
                    if (displayPropertys != null)
                    {
                        this.CurrentSong = await SongInformation.Create(displayPropertys.MusicProperties.AlbumTitle, string.IsNullOrWhiteSpace(displayPropertys.MusicProperties.Artist)?displayPropertys.MusicProperties.AlbumArtist : displayPropertys.MusicProperties.Artist, displayPropertys.MusicProperties.Title, displayPropertys.Thumbnail);
                    }
                    else
                    {
                        this.CurrentSong = null;
                    }
                }
                else
                {
                    await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => await SetCurrentSong(displayPropertys));
                }
            }
        }
Ejemplo n.º 11
0
 private async void Playlist_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
 {
     await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                                                   () =>
     {
         ShowCurrentlyPlayingSong();
     });
 }
 private void PlaybackList_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
 {
     var task = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         // Synchronize our UI with the currently-playing item.
         playlistView.SelectedIndex = (int)sender.CurrentItemIndex;
     });
 }
 private void PlaybackList_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
 {
     var task = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         // Synchronize our UI with the currently-playing item.
         playlistView.SelectedIndex = (int)sender.CurrentItemIndex;
     });
 }
 private void PlaybackList_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
 {
     var ignoreAwaitWarning = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         var currentItem            = sender.CurrentItem;
         playlistView.SelectedIndex = playbackList.Items.ToList().FindIndex(i => i == currentItem);
     });
 }
Ejemplo n.º 15
0
 private void MediaPlaybackList_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
 {
     var task = CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         int index = (int)sender.CurrentItemIndex;
         UpdateUI();
     });
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Provides a JSON object for Current Media PlaybackItem Changed Requested Event Args
        /// </summary>
        public static JsonObject ToJsonObject(this CurrentMediaPlaybackItemChangedEventArgs c)
        {
            var builder = new JsonBuilder("CurrentMediaPlaybackItemChangedEventArgs");

            builder.AddJsonValue("NewItem", c.NewItem?.ToJsonObject());
            builder.AddJsonValue("OldItem", c.OldItem?.ToJsonObject());
            builder.AddString("Reason", c.Reason);
            return(builder.GetJsonObject());
        }
Ejemplo n.º 17
0
 private void PlaybackList_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
 {
     if (StopOnNextTrack)
     {
         mediaPlayer.Pause();
         IsCurrentlyPlaying = false;
         StopOnNextTrack    = false;
     }
 }
Ejemplo n.º 18
0
        private void OnCurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            return;

            if (args.NewItem != null && _playlist.CurrentItemIndex == _playlist.Items.Count - 1)
            {
                if (_mapping.TryGetValue((string)args.NewItem.Source.CustomProperties["token"], out Message message))
                {
                    var offset = message.Content is MessageAudio ? 0 : -99;
                    var filter = message.Content is MessageAudio ? new SearchMessagesFilterAudio() : (SearchMessagesFilter) new SearchMessagesFilterVoiceNote();

                    _protoService.Send(new SearchChatMessages(message.ChatId, string.Empty, 0, message.Id, offset, 100, filter), result =>
                    {
                        if (result is Messages messages)
                        {
                            foreach (var add in message.Content is MessageAudio ? messages.MessagesData.OrderByDescending(x => x.Id) : messages.MessagesData.OrderBy(x => x.Id))
                            {
                                if (add.Id < message.Id && message.Content is MessageAudio)
                                {
                                    _playlist.Items.Add(GetPlaybackItem(add));
                                }
                                else if (add.Id > message.Id && message.Content is MessageVoiceNote)
                                {
                                    _playlist.Items.Add(GetPlaybackItem(add));
                                }
                            }
                        }
                    });
                }
            }

            if (args.NewItem == null)
            {
                //Execute.BeginOnUIThread(() => CurrentItem = null);
                //Dispose();

                //Debug.WriteLine("PlaybackService: Playback completed");
            }
            //else if (_mapping.TryGetValue(args.NewItem, out TLMessage message))
            //{
            //    Execute.BeginOnUIThread(() => CurrentItem = message);
            //    Debug.WriteLine("PlaybackService: Playing message " + message.Id);

            //    MarkAsRead(message);
            //}
            //else
            //{
            //    Execute.BeginOnUIThread(() => CurrentItem = null);
            //    Debug.WriteLine("PlaybackService: Current item changed, can't find related message");
            //}

            if (_queue != null && _queue.Count > 0)
            {
                //Enqueue(_queue.Dequeue(), false);
            }
        }
Ejemplo n.º 19
0
        private void PlaybackList_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            _mediaPlayer.PlaybackSession.Position = _newSegmentStartPosition;
            _newSegmentStartPosition = TimeSpan.Zero;

            var playbackList = _mediaPlayer.Source as MediaPlaybackList;

            playbackList.CurrentItemChanged -= PlaybackList_CurrentItemChanged;

            if (_mediaPlayer.PlaybackSession.PlaybackState != MediaPlaybackState.Playing)
            {
                _mediaPlayer.Play();
            }
        }
Ejemplo n.º 20
0
        //Updates the current panel above mediaelement and background when track changes.
        private async void Track_Changes(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs e)
        {
            await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                if (!mediaElement.MediaPlayer.IsLoopingEnabled)
                {
                    currentPlaying++;
                    currentPlaying %= queue.Count();
                }

                AudioFile af = queue[currentPlaying];
                Update_CurrentStatus(af);
            });
        }
Ejemplo n.º 21
0
        //</SnippetDeclareItemQueue>

        //<SnippetMediaPlaybackListItemChanged>
        private void MediaPlaybackList_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            _playbackItemQueue.Enqueue(args.OldItem);
            if (_playbackItemQueue.Count > maxCachedItems)
            {
                MediaPlaybackItem oldestItem = _playbackItemQueue.Dequeue();

                // If the oldest item doesn't have another entry in the queue and it's not the currently playing item
                if (!(oldestItem == null || _playbackItemQueue.Contains <MediaPlaybackItem>(oldestItem) || oldestItem != args.NewItem))
                {
                    oldestItem.Source.Reset();
                }
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        ///     Called when the current playing item changes
        /// </summary>
        private async void CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            await DispatcherHelper.ExecuteOnUIThreadAsync(async() =>
            {
                // Only perform the following actions if there is a new track
                if (args.NewItem == null)
                {
                    return;
                }

                if (Service.CurrentTrack == null)
                {
                    return;
                }

                var overlay = App.CurrentFrame.FindName("VideoOverlay") as MediaElement;

                if (overlay != null)
                {
                    if (Service.CurrentTrack.ServiceType == ServiceType.YouTube)
                    {
                        overlay.Source = new Uri(Service.CurrentTrack.VideoStreamUrl);
                        overlay.Play();
                    }
                    else
                    {
                        overlay.Opacity = 0;
                        overlay.Pause();
                        overlay.Source = null;
                    }
                }

                // Set the pin button text
                PinButtonText = TileHelper.IsTilePinned("Track_" + Service.CurrentTrack.Id) ? "Unpin" : "Pin";

                // Set the like button text
                LikeButtonText = await SoundByteV3Service.Current.ExistsAsync(ServiceType.SoundCloud, "/me/favorites/" + Service.CurrentTrack.Id)
                    ? "Unlike"
                    : "Like";

                // Set the repost button text
                RepostButtonText =
                    await SoundByteV3Service.Current.ExistsAsync(ServiceType.SoundCloud, "/e1/me/track_reposts/" + Service.CurrentTrack.Id)
                        ? "Unpost"
                        : "Repost";

                // Reload all the comments
                CommentItems.RefreshItems();
            });
        }
Ejemplo n.º 23
0
        //Updates song details when the song changes.
        public async void Playlist_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            if (!initialload)
            {
                SongListenInDB   = false;
                Listeneventcount = 0;
            }
            else
            {
                initialload = false;
            }

            await UpdateNowPlaying();
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Raised when playlist changes to a new track
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        void PlaybackListCurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            // Get the new item
            var item = args.NewItem;

            // Update the system view
            UpdateUVCOnNewTrack(item);

            // Get the current track
            if (item != null && item.Source.CustomProperties.ContainsKey(QuranTrackKey))
            {
                var json = item.Source.CustomProperties[QuranTrackKey] as string;
                MessageService.SendMessageToForeground(new TrackChangedMessage(QuranAudioTrack.FromString(json)));
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// When the current item of the list changes.
        /// </summary>
        /// <param name="sender">The list that called the change.</param>
        /// <param name="args">Information about the change. Includes the previous and new item.</param>
        private async void Playlist_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            int itemIndex = sender.Items.IndexOf(args.NewItem);

            if (itemIndex != -1)
            {
                NBPlayerState.CurrentSourceIndex = itemIndex;

                string mediaName = NBPlayerState.CurrentMediaList[(int)NBPlayerState.CurrentSourceIndex].Name;

                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    lblMediaTitle.Text = mediaName;
                });
            }
        }
Ejemplo n.º 26
0
        private async void PlaylistItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => {
                //var track = playList.CurrentItem.AudioTracks [0];

                if (playlistNames.Count <= 0)
                {
                    return;
                }
                if (!playlistNames.ContainsKey((int)playList.CurrentItemIndex))
                {
                    return;
                }

                musicName.Text = playlistNames [(int)playList.CurrentItemIndex];
            });
        }
Ejemplo n.º 27
0
        private void _playlist_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            if (CoreApplication.MainView.CoreWindow != null)
            {
                var t = CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => {
                    var item = args.NewItem;

                    if (item == null)
                    {
                        CurrentItem = null;
                    }
                    else
                    {
                        var index   = _playlist.Items.IndexOf(item);
                        CurrentItem = _songCollection[index];
                    }
                });
            }
        }
        private async void MediaPlaybackList_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            await UIDispatcher.RunAsync(CoreDispatcherPriority.High, () =>
           {
               var newItem = PlaybackList.Where(x => x.SourceObject == args.NewItem).FirstOrDefault();
               var oldItem = PlaybackList.Where(x => x.SourceObject == args.OldItem).FirstOrDefault();

               if (newItem != null)
               {
                   newItem.State = "Playing";
                   PlayingItemChanged?.Invoke(null, newItem);
               }

               if (oldItem != null)
               {
                   oldItem.State = string.Empty;
               }
           });
        }
Ejemplo n.º 29
0
        private async void MediaList_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            uint Index = sender.CurrentItemIndex;

            if (Index == 4294967295)
            {
                return;
            }
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                if (MusicList.ThisPage.FavouriteMusicCollection.Count != 0 && MediaControl.MediaPlayer.Source == MediaPlayList.FavouriteSongList)
                {
                    var PL = MusicList.ThisPage.FavouriteMusicCollection[Convert.ToInt32(Index)];

                    var bitmap            = new BitmapImage();
                    PicturePlaying.Source = bitmap;
                    bitmap.UriSource      = new Uri(PL.ImageUrl);
                }
            });
        }
Ejemplo n.º 30
0
        //当前播放的曲目改变时,即切换曲目时发生
        private void PlaybackList_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            // 获取更新的项目
            var item = args.NewItem;

            DebugWrite("PlaybackList_CurrentItemChanged: " + (item == null ? "null" : GetTrackId(item).ToString()), "BackgroundPlayer");
            //System.Diagnostics.Debugger.Break();
            //if (item == null)
            //    UpdateUVCOnNewTrack(null);

            //// 获取当前播放轨
            //Uri currentTrackId = null;
            //if (item != null)
            //    currentTrackId = item.Source.CustomProperties[TrackIdKey] as Uri;

            //// 通知前台切换或者保持
            //if (foregroundAppState == AppState.Active)
            //    MessageService.SendMediaMessageToForeground<Uri>(MediaMessageTypes.TrackChanged, currentTrackId);
            //else
            //    settinghelper.Write(TrackIdKey, currentTrackId?.ToString());
        }
Ejemplo n.º 31
0
        /// <summary>
        /// Raised when playlist changes to a new track
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        void OnCurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            MediaPlaybackItem item = args.NewItem;

            UpdateUVCOnNewTrack(item);

            string currentTrackId = null;

            if (item != null)
            {
                currentTrackId = GetTrackId(item);
            }

            if (foregroundAppState == AppState.Active)
            {
                MessageService.SendMessageToForeground(new TrackChangedMessage(currentTrackId));
            }
            else
            {
                ApplicationSettingsHelper.SaveSettingsValue(ApplicationSettingsConstants.TrackId, currentTrackId == null ? null : currentTrackId);
            }
        }
Ejemplo n.º 32
0
        /// <summary>
        /// Raised when playlist changes to a new track
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        void PlaybackList_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            // Get the new item
            var item = args.NewItem;

            Debug.WriteLine("PlaybackList_CurrentItemChanged: " + (item == null ? "null" : Convert.ToString(GetTrackId(item))));

            // Update the system view
            UpdateUVCOnNewTrack(item);

            // Get the current track
            Uri currentTrackId = null;

            if (item != null)
            {
                string trackIdKey = item.Source.CustomProperties[TrackIdKey].ToString();
                currentTrackId = new Uri(trackIdKey);
            }

            ApplicationSettingsHelper.SaveSettingsValue(ApplicationSettingsConstants.TrackId, currentTrackId == null ? null : currentTrackId.ToString());
            MessageService.SendMessageToForeground(this, new TrackChangedMessage(currentTrackId));
        } // Sprawdzone
 private async void PlaybackList_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
 {
     var item = args.NewItem;
     // Update the system view
     if (item == null)
         return;
     var currentTrackId = item.Source.CustomProperties[TrackIdKey] as string;
     UpdateUVCOnNewTrack(item);
     // Get the current track
     
     // Notify foreground of change or persist for later
     MessageService.SendMessageToForeground(new BackPlaybackChangedMessage(NowState, Songs.Find(x => x.MainKey == currentTrackId)));
     ThreadPool.RunAsync(async (work) =>
     {
         var bytestream = await FileHelper.FetchArtwork(FileList.Find(x => currentTrackId == ((StorageFile)x).Path));
         if (bytestream != null)
         {
             MessageService.SendMessageToForeground(new UpdateArtworkMessage(bytestream));
             UpdateUVCOnNewTrack(bytestream);
         }
     });
 }
 private async void SubscribedPlaybackList_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
 {
     if (disposed) return;
     await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         if (disposed) return;
         HandlePlaybackListChanges(sender.Items);
     });
 }
        /// <summary>
        /// Raised when playlist changes to a new track
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        void PlaybackList_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            // Get the new item
            var item = args.NewItem;
            Debug.WriteLine("PlaybackList_CurrentItemChanged: " + (item == null ? "null" : GetTrackId(item).ToString()));

            // Update the system view
            UpdateUVCOnNewTrack(item);

            // Get the current track
            string currentTrackId = null;
            if (item != null)
                currentTrackId = item.Source.CustomProperties[TrackIdKey] as string;

            // Notify foreground of change or persist for later
            if (foregroundAppState == AppState.Active)
                MessageService.SendMessageToForeground(new TrackChangedMessage(currentTrackId));
            else
                ApplicationSettingsHelper.SaveSettingsValue(TrackIdKey, currentTrackId?.ToString());
        }
        /// <summary>
        /// Raised when playlist changes to a new track
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        void PlaybackListCurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            // Get the new item
            var item = args.NewItem;

            // Update the system view
            UpdateUVCOnNewTrack(item);

            // Get the current track
            if (item != null && item.Source.CustomProperties.ContainsKey(QuranTrackKey))
            {
                var json = item.Source.CustomProperties[QuranTrackKey] as string;
                MessageService.SendMessageToForeground(new TrackChangedMessage(QuranAudioTrack.FromString(json)));
            }      
        }
        /// <summary>
        /// Raised when playlist changes to a new track
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        void PlaybackList_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            //Uri s =    GetCurrentTrackId();

            // Get the new item
            var item = args.NewItem;
            Debug.WriteLine("PlaybackList_CurrentItemChanged: " + (item == null ? "null" : Convert.ToString(GetTrackId(item))));

            // Update the system view
            UpdateUVCOnNewTrack(item);

            // Get the current track
            Uri currentTrackId = null;
            if (item != null)
            {
                string trackIdKey = item.Source.CustomProperties[TrackIdKey].ToString();
                currentTrackId = new Uri(trackIdKey);
            }

            ApplicationSettingsHelper.SaveSettingsValue(ApplicationSettingsConstants.TrackId, currentTrackId == null ? null : currentTrackId.ToString());
            MessageService.SendMessageToForeground(new TrackChangedMessage(currentTrackId));
        }
Ejemplo n.º 38
0
 private void MediaPlaybackList_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
 {
     int index;
     if ((index = _playbackItems?.IndexOf(args.NewItem) ?? -1) != -1)
     {
         var playlist = _playlist;
         if (index < playlist?.Count)
         {
             _currentTrack = playlist[index];
             Execute.BeginOnUIThread(() => _audioControllerHandler.OnCurrentTrackChanged(_currentTrack));
         }
     }
 }
 private void PlaybackList_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
 {
     var ignoreAwaitWarning = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         var currentItem = sender.CurrentItem;
         playlistView.SelectedIndex = playbackList.Items.ToList().FindIndex(i => i == currentItem);
     });
 }
Ejemplo n.º 40
0
        private void MediaPlaybackListOnCurrentItemChanged(MediaPlaybackList sender,
            CurrentMediaPlaybackItemChangedEventArgs args)
        {
            // Get the new item
            var item = args.NewItem;

            // Get the current track
            var currentTrack = item?.Source?.Queue();

            // Update the system view
            _smtcWrapper.UpdateUvcOnNewTrack(currentTrack?.Track);

            if (currentTrack != null)
            {
                Debug.WriteLine("PlaybackList_CurrentItemChanged: " + currentTrack.Id);

                // Notify foreground of change or persist for later
                if (ForegroundAppState == AppState.Active)
                    MessageHelper.SendMessageToForeground(new TrackChangedMessage(currentTrack.Id));

                _settingsUtility.Write(ApplicationSettingsConstants.QueueId, currentTrack.Id);
            }
        }
Ejemplo n.º 41
0
 private void playbackList_CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
 {
     sender.SetShuffledItems(new[] { args.NewItem });
 }