Exemple #1
0
        public void RemoveTracks()
        {
            PlaylistCollection.DeleteTracksByIndices(selectedIndices.ToArray(), TracklistGUID);
            for (int i = selectedIndices.Count - 1; i >= 0; i--)
            {
                soundtracks.RemoveAt(selectedIndices[i]);
            }

            Playlist pl = PlaylistCollection.GetPlaylist(TracklistGUID);
            UpdatePlaylistEventArgs e = new UpdatePlaylistEventArgs(pl, PlayingTrack);

            PlaylistIsUpdatedEvent?.Invoke(e);
        }
Exemple #2
0
        public void UpdateQueue(UpdatePlaylistEventArgs e)
        {
            if (this.PlayerStatus == PlaybackState.Stopped)
            {
                return;
            }
            // If given playlist to be updated is not played currently, there is no need to update.
            if (this.CurrentPlaylistGUID != e.UpdatedPlaylist.GUID)
            {
                return;
            }

            trackQueue = new TrackQueue(e.UpdatedPlaylist, e.IndexOfPlayingTrack, (PlaybackMode)Properties.Settings.Default.TaskPlaybackMode);

            if (trackQueue.Count != 0)
            {
                TrackInfo nextTrack;
                trackQueue.Next(out nextTrack);
            }
        }
 public void UpdateTrackList(UpdatePlaylistEventArgs e)
 {
     trackLists.First(x => x.GUID == e.UpdatedPlaylist.GUID).Soundtracks = e.UpdatedPlaylist.Soundtracks;
 }
Exemple #4
0
        void IDropTarget.Drop(IDropInfo dropInfo)
        {
            DataObject dataObject = dropInfo.Data as DataObject;

            if (dataObject != null && dataObject.ContainsFileDropList())
            {
                IEnumerable <string> dropList = dataObject.GetFileDropList().Cast <string>();
                List <TrackInfo>     tlist    = new List <TrackInfo>();

                foreach (string filePath in dropList)
                {
                    if (!MPLiteConstant.validFileType.Contains(Path.GetExtension(filePath)))
                    {
                        continue;
                    }
                    try
                    {
                        TrackInfo track = TrackInfo.ParseSource(filePath);
                        tlist.Add(track);
                        Soundtracks.Add(track);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }

                if (tlist.Count != 0)
                {
                    Playlist pl = PlaylistCollection.UpdatePlaylist(tlist, TracklistName);
                    UpdatePlaylistEventArgs e = new UpdatePlaylistEventArgs(pl, PlayingTrack);
                    PlaylistIsUpdatedEvent?.Invoke(e);
                }
            }
            else
            {
                // workaround: There is a bug that user can drag item from the gap between two items.
                //    It triggers DragEvent without SelectionChangeEvent. So that `selectedIndices` will be empty.
                if (selectedIndices.Count == 0)
                {
                    return;
                }

                // Reorder tracks
                List <TrackInfo> tracks;

                if ((dropInfo.Data as List <TrackInfo>) == null)
                {
                    // Single file is dropped
                    tracks = new List <TrackInfo>();
                    tracks.Add(dropInfo.Data as TrackInfo);
                }
                else
                {
                    // Multiple files is dropped
                    tracks = dropInfo.Data as List <TrackInfo>;
                }

                Playlist pl = PlaylistCollection.ReorderTracks(TracklistGUID, SelectedIndices, dropInfo.InsertIndex);
                if (pl == null)
                {
                    return;
                }
                UpdateSoundtracks(pl.Soundtracks);

                UpdatePlaylistEventArgs e = new UpdatePlaylistEventArgs(pl, PlayingTrack);
                PlaylistIsUpdatedEvent?.Invoke(e);

                // reset PlayStatus
                if (PlayingTrack != null)
                {
                    TrackInfo track = soundtracks.FirstOrDefault(x => x.GUID == PlayingTrack.GUID);
                    if (track != null)
                    {
                        track.TrackStatus = PlayingTrack.TrackStatus;
                    }
                }
            }
        }
Exemple #5
0
 private void OnPlaylistIsUpdated(UpdatePlaylistEventArgs e)
 {
     PlaylistIsUpdatedEvent(e);
 }