コード例 #1
0
        public async Task GoBack()
        {
            _isOpeningTrack = true;

            if (CurrentPlaylist == null || !CurrentPlaylist.ContainsPlayableTracks())
            {
                return;
            }

            if (CurrentTrack == null)
            {
                OpenPlayable(await CurrentPlaylist.GetLastTrack(), CurrentPlaylist).Forget();
                return;
            }

            if (_tempHistory.Count > 1)                        //Check if there are more than two tracks, because the current track is the last one in the list
            {
                _tempHistory.RemoveAt(_tempHistory.Count - 1); //This is the current track
                var newTrack = _tempHistory.Last();
                OpenPlayable(newTrack.Item2, newTrack.Item1, true, false, false).Forget();
            }
            else
            {
                OpenPlayable(await CurrentPlaylist.GetPreviousTrack(CurrentTrack), CurrentPlaylist, true, false, false)
                .Forget();
            }
        }
コード例 #2
0
        public async Task PlayPause()
        {
            if (IsPlaying)
            {
                await Task.Run(() => AudioPlayerEngine.Pause());

                IsPlaying = false;
                await CurrentPlaylist.SetState(CurrentTrack.Track, AudioPlayerState.Paused);
            }
            else
            {
                TrackStateViewModel song;
                if (CurrentPlaylist.CurrentEntry != null)
                {
                    song = CurrentPlaylist.CurrentEntry;
                }
                else if (CurrentPlaylist.Count > 0)
                {
                    song = CurrentPlaylist[0];
                }
                else
                {
                    return;
                }

                await Play(song);
            }
        }
コード例 #3
0
        public PlaylistSidePaneContentViewModel(
            MediaPlayer mediaPlayer,
            HohoemaPlaylist playerModel,
            PlaylistSettings playlistSettings,
            PageManager pageManager
            )
        {
            MediaPlayer      = mediaPlayer;
            HohoemaPlaylist  = playerModel;
            PlaylistSettings = playlistSettings;
            PageManager      = pageManager;

            CurrentPlaylist     = playerModel.CurrentPlaylist;
            CurrentPlayingItem  = playerModel.Player.Current;
            CurrentPlaylistName = new ReactiveProperty <string>(CurrentWindowContextScheduler, HohoemaPlaylist.CurrentPlaylist?.Label)
                                  .AddTo(_CompositeDisposable);
            IsShuffleEnabled = PlaylistSettings.ToReactivePropertyAsSynchronized(x => x.IsShuffleEnable, CurrentWindowContextScheduler)
                               .AddTo(_CompositeDisposable);

            IsTrackRepeatModeEnable = PlaylistSettings.ObserveProperty(x => x.RepeatMode)
                                      .Select(x => x == MediaPlaybackAutoRepeatMode.Track)
                                      .ToReactiveProperty(CurrentWindowContextScheduler)
                                      .AddTo(_CompositeDisposable);
            IsListRepeatModeEnable = PlaylistSettings.ObserveProperty(x => x.RepeatMode)
                                     .Select(x => x == MediaPlaybackAutoRepeatMode.List)
                                     .ToReactiveProperty(CurrentWindowContextScheduler)
                                     .AddTo(_CompositeDisposable);

            IsTrackRepeatModeEnable.Subscribe(x =>
            {
                MediaPlayer.IsLoopingEnabled = x;
            })
            .AddTo(_CompositeDisposable);


            IsReverseEnabled = PlaylistSettings.ToReactivePropertyAsSynchronized(x => x.IsReverseModeEnable, CurrentWindowContextScheduler)
                               .AddTo(_CompositeDisposable);

            PlaylistCanGoBack = HohoemaPlaylist.Player.ObserveProperty(x => x.CanGoBack)
                                .ToReactiveProperty(CurrentWindowContextScheduler)
                                .AddTo(_CompositeDisposable);
            PlaylistCanGoNext = HohoemaPlaylist.Player.ObserveProperty(x => x.CanGoNext)
                                .ToReactiveProperty(CurrentWindowContextScheduler)
                                .AddTo(_CompositeDisposable);

            PlaylistItems = CurrentPlaylist.Select(x =>
            {
                var video = Database.NicoVideoDb.Get(x);
                return(new PlaylistItem()
                {
                    ContentId = x,
                    Title = video.Title,
                    Owner = CurrentPlaylist,
                    Type = PlaylistItemType.Video
                });
            }).ToObservable()
                            .ToReadOnlyReactiveCollection(scheduler: CurrentWindowContextScheduler)
                            .AddTo(_CompositeDisposable);
            RaisePropertyChanged(nameof(PlaylistItems));
        }
コード例 #4
0
 private TrackStateViewModel GetRandom()
 {
     if (CurrentPlaylist.MoveRandom())
     {
         return(CurrentPlaylist.CurrentEntry);
     }
     return(null);
 }
コード例 #5
0
ファイル: MusicManager.cs プロジェクト: timyuheng/AMP
        public async void GoForward()
        {
            if (CurrentPlaylist == null || CurrentPlaylist.Tracks.Count == 0)
            {
                return;
            }
            PlayableBase nextTrack;

            if (Queue.HasTracks)
            {
                var tuple = Queue.PlayNextTrack();
                nextTrack       = tuple.Item1;
                CurrentPlaylist = tuple.Item2;
            }
            else
            {
                int currenttrackindex = CurrentPlaylist.Tracks.IndexOf(CSCoreEngine.CurrentTrack);
                int nexttrackindex    = currenttrackindex;
                if (CheckIfTracksExists(CurrentPlaylist))
                {
                    if (IsShuffleEnabled)
                    {
                        nextTrack = CurrentPlaylist.GetRandomTrack(CSCoreEngine.CurrentTrack);
                        if (nextTrack == null)
                        {
                            return;
                        }
                    }
                    else
                    {
                        while (true)
                        {
                            nexttrackindex++;
                            if (CurrentPlaylist.Tracks.Count - 1 < nexttrackindex)
                            {
                                nexttrackindex = 0;
                            }
                            if (CurrentPlaylist.Tracks[nexttrackindex].TrackExists)
                            {
                                break;
                            }
                        }
                        nextTrack = CurrentPlaylist.Tracks[nexttrackindex];
                    }
                }
                else
                {
                    return;
                }
            }
            if (nextTrack.TrackExists)
            {
                if (await CSCoreEngine.OpenTrack(nextTrack))
                {
                    CSCoreEngine.TogglePlayPause();
                }
            }
        }
コード例 #6
0
        public void RemoveTrack(int index)
        {
            var media = mPlayer.currentPlaylist.Item[index];
            var count = CurrentPlaylist.count;

            CurrentPlaylist.removeItem(media);
            var countafter = CurrentPlaylist.count;

            SetCurrentPlaylistSongUrl(CurrentPlaylist);
        }
コード例 #7
0
        private void Unsubscribe(IEnumerable <IPlaylist> playlists)
        {
            foreach (IPlaylist playlist in playlists ?? Enumerable.Empty <IPlaylist>())
            {
                CurrentPlaylist.Unsubscribe(playlist);
                OtherPlaylists.Unsubscribe(playlist);

                AllPlaylists.Unsubscribe(playlist);
            }
        }
コード例 #8
0
        private void OnCurrentPlaylistChanged(object sender, CurrentPlaylistChangedEventArgs e)
        {
            CurrentPlaylist.Unsubscribe(e.OldCurrentPlaylist);
            CurrentPlaylist.Subscribe(e.NewCurrentPlaylist);

            OtherPlaylists.Unsubscribe(e.NewCurrentPlaylist);
            OtherPlaylists.Subscribe(e.OldCurrentPlaylist);

            CurrentPlaylistChanged?.Invoke(this, new SubscriptionsEventArgs <ILibrary, CurrentPlaylistChangedEventArgs>(sender, e));
        }
コード例 #9
0
 /// <summary>
 /// Adds Items to the Playlist.
 /// </summary>
 /// <param name="item">
 /// A Playlistem Object.
 /// </param>
 public static void PlaylistAddItems(MediaItem item)
 {
     //if (item.IsDir)
     //{
     //    AddDir(item.AlbumID);
     //}
     //else
     //{
     //    CurrentPlaylist.Add(item);
     //}
     CurrentPlaylist.Add(item);
     Playback.AddToPlaylist(item);
 }
コード例 #10
0
ファイル: ViewModel.cs プロジェクト: ShelbyBoss/FolderMusic
        public void UpdateCurrentPlaylistIndexAndRest()
        {
            UpdatePlaylistIndex();

            NotifyPropertyChanged("CurrentPlaylist");

            CurrentPlaylist.UpdateName();
            CurrentPlaylist.UpdateSongsAndShuffleListSongs();
            CurrentPlaylist.UpdateCurrentSong();
            
            CurrentPlaylist.UpdateLoopIcon();
            CurrentPlaylist.UpdateShuffleIcon();
        }
コード例 #11
0
ファイル: Library.cs プロジェクト: justinhachemeister/MiSharp
        /// <summary>
        ///     Adds the specified song to the end of the playlist.
        ///     This method is only available in administrator mode.
        /// </summary>
        /// <param name="songList">The songs to add to the end of the playlist.</param>
        public void AddSongsToPlaylist(IEnumerable <Song> songList)
        {
            if (songList == null)
            {
                Throw.ArgumentNullException(() => songList);
            }


            CurrentPlaylist.AddSongs(songList.ToList());
            // Copy the sequence to a list, so that the enumeration doesn't gets modified

            PlaylistChanged.RaiseSafe(this, EventArgs.Empty);
        }
コード例 #12
0
 void RemoveSelecurrent(Track track)
 {
     if (CurrentTrack == track)
     {
         Stop();
         if (!IsLoopOne)
         {
             PlayForward();
         }
     }
     CurrentPlaylist.RemoveTrack(track);
     SelectedPlaylist.RemoveTrack(track);
 }
コード例 #13
0
ファイル: PlaylistGenerator.cs プロジェクト: CarlosVV/mediavf
        /// <summary>
        /// Stops playlist creation
        /// </summary>
        public void Stop()
        {
            // stop scanning
            ScanTimer.Stop();

            // save current playlist
            if (CurrentPlaylist != null)
            {
                CurrentPlaylist.SavePlaylist(OutputFolder);
            }

            IsRunning = false;
        }
コード例 #14
0
 void RemoveInAllSongs(Track track)
 {
     if (CurrentTrack == track)
     {
         Stop();
         if (!IsLoopOne)
         {
             PlayForward();
         }
     }
     CurrentPlaylist.RemoveTrack(track);
     SelectedPlaylist.RemoveTrack(track);
     Updater.DeleteOneTrack(track);
 }
コード例 #15
0
 private void PlaylistElementClicked(object param)
 {
     PlayQueue.Content      = CurrentPlaylist.GetRange(SelectedPlaylistElem, CurrentPlaylist.Count - SelectedPlaylistElem);
     DisplayingImage        = false;
     mediaPlayer.NowPlaying = PlayQueue.Content[0];
     OnPropertyChanged("NowPlayingTitle");
     OnPropertyChanged("NowPlayingArtist");
     Console.WriteLine("Music in queue: " + PlayQueue.Content.Count);
     CancelMedia();
     this._myMediaElement.Source = new Uri(PlayQueue.Content[0].File);
     Console.WriteLine("New source: " + this._myMediaElement.Source);
     PlayMedia(null);
     StartTimer();
 }
コード例 #16
0
        public async Task PlayPrev()
        {
            IsPlaying = false;
            AudioPlayerEngine.Stop();
            await CurrentPlaylist.SetState(CurrentTrack, AudioPlayerState.None);

            CurrentTrack = null;
            TrackStateViewModel song = await Task.Run(() => GetPreviousSong(RepeatState, ShuffleState));

            if (song != null)
            {
                await Play(song);
            }
        }
コード例 #17
0
ファイル: PlaylistGenerator.cs プロジェクト: CarlosVV/mediavf
        /// <summary>
        /// Starts a new playlist by saving the current and creating new
        /// </summary>
        public void StartNewPlaylist()
        {
            // save playlist
            if (CurrentPlaylist != null && !string.IsNullOrEmpty(OutputFolder))
            {
                CurrentPlaylist.SavePlaylist(OutputFolder);
            }

            // create new
            CurrentPlaylist = new ZunePlaylist(DateTime.Now.ToString());

            // reset created time
            PlaylistCreated = DateTime.Now;
            LastScan        = DateTime.Now;
        }
コード例 #18
0
ファイル: Library.cs プロジェクト: justinhachemeister/MiSharp
        /// <summary>
        ///     Adds the song to the end of the playlist.
        ///     This method throws an exception, if there is an outstanding timeout.
        /// </summary>
        /// <param name="song">The song to add to the end of the playlist.</param>
        public void AddSongToPlaylist(Song song)
        {
            if (song == null)
            {
                Throw.ArgumentNullException(() => song);
            }

            if (CurrentPlaylist == null)
            {
                CurrentPlaylist = new Playlist("Default");
            }
            CurrentPlaylist.AddSongs(new[] { song });

            PlaylistChanged.RaiseSafe(this, EventArgs.Empty);
        }
コード例 #19
0
        public void Sort(string attribute)
        {
            bool sortAsc = bool.Parse(CurrentPlaylist.getItemInfo("SortAscending"));

            if (CurrentPlaylist.getItemInfo("SortAttribute").Equals(attribute))
            {
                CurrentPlaylist.setItemInfo("SortAscending", (!sortAsc).ToString());
            }
            else
            {
                CurrentPlaylist.setItemInfo("SortAttribute", attribute);
                CurrentPlaylist.setItemInfo("SortAscending", "true");
            }
            SetCurrentPlaylistSongUrl(CurrentPlaylist);
            currentPlaylistSongUrl = PlaylistsUrl[CurrentPlaylist.name];
        }
コード例 #20
0
        private void Subscribe(IEnumerable <IPlaylist> playlists)
        {
            foreach (IPlaylist playlist in playlists ?? Enumerable.Empty <IPlaylist>())
            {
                bool isCurrentPlaylist = Equals(playlist, playlist.Parent.Parent.CurrentPlaylist);

                if (isCurrentPlaylist)
                {
                    CurrentPlaylist.Subscribe(playlist);
                }
                else
                {
                    OtherPlaylists.Subscribe(playlist);
                }

                AllPlaylists.Subscribe(playlist);
            }
        }
コード例 #21
0
        public TrackStateViewModel GetPreviousSong(bool repeat, bool random)
        {
            if (random)
            {
                return(GetRandom());
            }
            if (!repeat)
            {
                if (CurrentPlaylist.MovePrevious())
                {
                    return(CurrentPlaylist.CurrentEntry);
                }
            }
            else if (CurrentPlaylist.MovePreviousOrLast())
            {
                return(CurrentPlaylist.CurrentEntry);
            }

            return(null);
        }
コード例 #22
0
        public TrackStateViewModel GetNextSong(bool repeat, bool random)
        {
            if (random)
            {
                return(GetRandom());
            }
            if (!repeat)
            {
                if (CurrentPlaylist.MoveNext())
                {
                    return(CurrentPlaylist.CurrentEntry);
                }
            }
            else if (CurrentPlaylist.MoveNextOrFirst())
            {
                return(CurrentPlaylist.CurrentEntry);
            }

            return(null);
        }
コード例 #23
0
ファイル: PlaylistGenerator.cs プロジェクト: CarlosVV/mediavf
        /// <summary>
        /// Scans the scan directory for new files and adds them to the playlist
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Scan()
        {
            // reset playlist
            if (DateTime.Now.Subtract(PlaylistCreated) >= PlaylistCreationInterval)
            {
                StartNewPlaylist();
            }

            // get new files
            List <string> newFiles = GetNewFiles();

            // add new files to playlist
            if (newFiles != null && newFiles.Count > 0)
            {
                newFiles.ForEach(nf => CurrentPlaylist.AddFileToPlaylist(nf));
            }

            // set current scan time
            LastScan = DateTime.Now;
        }
コード例 #24
0
        public static async Task PreparePlaylistAsync()
        {
            Debug.WriteLine("> Load playlist locally");
            var loadedPlaylist = await LoadFromFileAsync();

            if (CurrentPlaylist == null)
            {
                CurrentPlaylist = loadedPlaylist ?? new Playlist();
            }
            else
            {
                CurrentPlaylist.Clear();
                if (loadedPlaylist.Entries.Count > 0)
                {
                    CurrentPlaylist.Entries.AddRange(loadedPlaylist.Entries.ToList());
                    CurrentPlaylist.CurrentIndex = loadedPlaylist.CurrentIndex;
                }
            }

            // Add waiting episodes
            CurrentPlaylist.AddEpisodes(EpisodesToAdd);

            // Cleanup
            var wrongEpisodes = CurrentPlaylist.Entries.Where(e => e.Episode == null).ToArray();

            foreach (var wrongEpisode in wrongEpisodes)
            {
                CurrentPlaylist.Entries.Remove(wrongEpisode);
            }

            // Check limits
            if (CurrentPlaylist.CurrentIndex >= CurrentPlaylist.Entries.Count)
            {
                CurrentPlaylist.CurrentIndex = CurrentPlaylist.Entries.Count - 1;
            }

            if (CurrentPlaylist.CurrentIndex < 0 && CurrentPlaylist.Entries.Count > 0)
            {
                CurrentPlaylist.CurrentIndex = 0;
            }
        }
コード例 #25
0
 public async Task Play(TrackStateViewModel song)
 {
     if (CurrentTrack == null || !Equals(CurrentTrack, song))
     {
         if (CurrentPlaylist.MoveToEntry(song))
         {
             CurrentTrack = CurrentPlaylist.CurrentEntry;
             await Task.Run(() =>
             {
                 AudioPlayerEngine.Stop();
                 AudioPlayerEngine.Load(CurrentPlaylist.CurrentEntry.Track.Model);
                 AudioPlayerEngine.Play();
             });
         }
     }
     else
     {
         AudioPlayerEngine.Resume();
     }
     IsPlaying = true;
     await CurrentPlaylist.SetState(song, AudioPlayerState.Playing);
 }
コード例 #26
0
ファイル: Library.cs プロジェクト: justinhachemeister/MiSharp
        private void InternPlayNextSong()
        {
            if (!CurrentPlaylist.CanPlayNextSong || !CurrentPlaylist.CurrentSongIndex.HasValue)
            {
                throw new InvalidOperationException("The next song couldn't be played.");
            }

            int nextIndex = CurrentPlaylist.CurrentSongIndex.Value + 1;

            // We want the to swap the songs, if the song that should be played next is currently caching
            if (CurrentPlaylist.ContainsIndex(nextIndex + 1))
            {
                PlaylistEntry nextReady = CurrentPlaylist
                                          .Skip(nextIndex)
                                          .FirstOrDefault();

                if (nextReady != null)
                {
                    CurrentPlaylist.InsertMove(nextReady.Index, nextIndex);
                }
            }

            InternPlaySong(nextIndex);
        }
コード例 #27
0
        public async Task GoForward(bool crossfade)
        {
            IPlayable track;

            _isOpeningTrack = true;
            if (Queue.QueueItems.Any())
            {
                track = Queue.GetNextPlayable();
                QueuePlaying?.Invoke(this, EventArgs.Empty);
            }
            else
            {
                if (CurrentPlaylist == null || !CurrentPlaylist.ContainsPlayableTracks())
                {
                    return;
                }

                track = await(CurrentPlayMode == PlayMode.Default
                    ? CurrentPlaylist.GetNextTrack(CurrentTrack)
                    : CurrentPlaylist.GetShuffleTrack());
            }

            await OpenPlayable(track, CurrentPlaylist, true, crossfade, true);
        }
コード例 #28
0
        async void chimneyMpdServer_OnLoad(object sender, ResponseEventArgs e)
        {
            string playlistName = string.Empty;

            int start = 0;
            int end = 0;

            bool suc = false;

            if (e.arguments.Count > 0)
            {
                playlistName = e.arguments[0];

                if (e.arguments.Count > 1)
                {
                    string[] par = e.arguments[1].Split(new char[] { ':' });
                    suc = int.TryParse(par[1], out start);

                    if (suc && par.Length > 1) suc = int.TryParse(par[2], out end);
                    else end = start;
                }
            }

            var playlistToAddFrom = await Dbconnection.FindAsync<Playlist>(o => o.Name == playlistName);

            if(!suc && playlistToAddFrom != null)
            {
                end = await Dbconnection.ExecuteScalarAsync<int>("SELECT COUNT(*) FROM PlaylistFiles WHERE PlaylistId = " + playlistToAddFrom.PlaylistId);
            }

            if(playlistToAddFrom != null)
            {
                var plFiles = await Dbconnection.QueryAsync<PlaylistFile>("SELECT * FROM PlaylistFiles WHERE PlaylistId = " + playlistToAddFrom.PlaylistId
                    + " AND Postion >= " + start + " AND Position < " + end);


                foreach(PlaylistFile plFile in plFiles)
                {
                    CurrentPlaylist newCurrentPlaylistItem = new CurrentPlaylist()
                    {
                        FileId = (plFile.IsUri) ? -1 : plFile.FileId,
                        IsUri = plFile.IsUri,
                        Uri = plFile.Uri,
                        PositionId = await Dbconnection.ExecuteScalarAsync<int>("SELECT COUNT(*) FROM CurrentPlaylist")
                    };

                    await Dbconnection.InsertAsync(newCurrentPlaylistItem);
                }
            }

            chimneyMpdServer.AppendResponse(string.Empty, e.id, e.position);

            if (OnIdleEvent != null) OnIdleEvent(this, new IdleEventArgs("playlist"));
        }
コード例 #29
0
        async void chimneyMpdServer_OnAdd(object sender, ResponseEventArgs e)
        {
            bool suc = true;

            string uri = string.Empty;

            File file = null;

            bool addasUri = false;

            if(e.arguments.Count > 0)
            {
                uri = e.arguments[0];

                file = await Dbconnection.FindAsync<File>(o => o.RelativePath.Equals(uri));

                if (file == null) addasUri = true;
            }

            if (file != null || addasUri)
            {
                CurrentPlaylist newCurrentPlaylistItem = new CurrentPlaylist()
                {
                    FileId = (addasUri) ? -1 : file.FileId,
                    IsUri = addasUri,
                    Uri = (addasUri) ? uri : file.FilePath,
                    Bitrate = (addasUri) ? 0 : file.Bitrate,
                    PositionId = await Dbconnection.ExecuteScalarAsync<int>("SELECT COUNT(*) FROM CurrentPlaylist")
                };

                await Dbconnection.InsertAsync(newCurrentPlaylistItem);
            }
            else
            {
                //
                // Get the uri from arguments, if empty uri is empty
                //
                var directory = (e.arguments.Count > 0) ? await Dbconnection.Table<Directory>().Where(o => o.RelativePath.Equals(e.arguments[0])).FirstAsync() : null;

                //
                // Get the sub directories for the the uri directories
                //
                var subDirQuery = Dbconnection.Table<Directory>().Where(o => o.RelativePath.StartsWith(directory.RelativePath) || directory.RelativePath.Equals(string.Empty));
                var subDirectories = await subDirQuery.ToListAsync();
                foreach (Directory subdir in subDirectories)
                {
                    //
                    // Get all files in the current uri
                    //
                    var subfiles = await Dbconnection.QueryAsync<File>("SELECT * FROM Files WHERE Files.DirectoryId = " + subdir.DirectoryId);
                    foreach (File subfile in subfiles)
                    {
                        CurrentPlaylist newCurrentPlaylistItem = new CurrentPlaylist()
                        {
                            FileId = subfile.FileId,
                            PositionId = await Dbconnection.ExecuteScalarAsync<int>("SELECT COUNT(*) FROM CurrentPlaylist")
                        };

                        await Dbconnection.InsertAsync(newCurrentPlaylistItem);
                    }
                }
            }


            if (suc) chimneyMpdServer.AppendResponse(string.Empty, e.id, e.position);
            else
            {
                string errorfile = string.Empty;
                if (e.arguments.Count > 0) errorfile = e.arguments.First<string>();
                chimneyMpdServer.ErrorResponse(MPDKeyWords.Response.ACK + " [50@0] {add} could not add file:" + " \"" + errorfile + "\"", e.id, e.position);
            }

            if (OnIdleEvent != null) OnIdleEvent(this, new IdleEventArgs("playlist"));

        }
コード例 #30
0
        async void chimneyMpdServer_OnAddId(object sender, ResponseEventArgs e)
        {
            bool suc = false;

            int id = 0;

            File file = null;
  
            if (e.arguments.Count > 0)
            {
                string uri = e.arguments[0];
                //var files = await Dbconnection.QueryAsync<File>("SELECT * FROM Files WHERE RelativePath = \"" + uri + "\"");
                //file = (files.Count > 0) ? files[0] : null;

                file = await Dbconnection.FindAsync<File>(o => o.RelativePath.Equals(uri));

                //var query = Dbconnection.Table<File>().Where(o => o.RelativePath.Equals(uri));
                //file = await query.FirstAsync();
            }

            int position = -1;

            if (e.arguments.Count > 1) suc = int.TryParse(e.arguments[1], out position);
            else suc = false;

            position = (suc) ? position : -1;

            if (file != null)
            {
                int currentPlaylistCount = await Dbconnection.ExecuteScalarAsync<int>("SELECT COUNT(*) FROM CurrentPlaylist");

                position = (position <= currentPlaylistCount && position >= 0) ? position : currentPlaylistCount;

                if (position != currentPlaylistCount)
                {
                    var affectedFiles = await Dbconnection.QueryAsync<CurrentPlaylist>("UPDATE CurrentPlaylist SET PositionId=PositionId+1 WHERE PositionId >= " + position);
                }

                CurrentPlaylist newCurrentPlaylistItem = new CurrentPlaylist()
                {
                    FileId = file.FileId,
                    PositionId = position,
                    Bitrate = file.Bitrate,
                    IsUri = false,
                    Uri = file.FilePath
                };

                await Dbconnection.InsertAsync(newCurrentPlaylistItem);

                suc = true;

                id = file.FileId;
            }
          
            if (suc) 
            {
                chimneyMpdServer.AppendResponse("Id: " + id + "\n", e.id, e.position);
            }
            else
            {
                string errorfile = string.Empty;
                if (e.arguments.Count > 0) errorfile = e.arguments.First<string>();
                chimneyMpdServer.ErrorResponse(MPDKeyWords.Response.ACK + " [50@0] {add} could not add file:" + " \"" + errorfile + "\"", e.id, e.position);
            }

            if (OnIdleEvent != null) OnIdleEvent(this, new IdleEventArgs("playlist"));

        }
コード例 #31
0
 public void Handle(List <Track> message)
 {
     CurrentPlaylist.AddRange(message);
 }
コード例 #32
0
 public void PreviousTrack()
 {
     Play(CurrentPlaylist.Previous());
 }
コード例 #33
0
 public void SkipTrack()
 {
     Play(CurrentPlaylist.Next());
 }