Beispiel #1
0
        private static ResourceSearchInstance Build(PlaylistDatabase database)
        {
            Log.Debug("Building suffix array...");
            var timer = new Stopwatch();

            timer.Start();
            var loadMs = timer.ElapsedMilliseconds;

            timer.Restart();
            var inst = new ResourceSearchInstance(database.UniqueResources);

            Log.Info($"Built suffix array (loading playlists {loadMs}ms, build {timer.ElapsedMilliseconds}ms)");
            return(inst);
        }
Beispiel #2
0
 protected override Task RemoveSongInternal(int index)
 {
     return(TaskEx.Run(() => {
         PlaylistDatabase.Delete(index);
         if (index == Index)
         {
             PlaylistDatabase.SetIndex(NO_POSITION);
         }
         else if (index >= 0 && index < Index && Index > 0)
         {
             // A track has been removed from "above" the currently playing track,
             // so the Index needs to adapt and move one step up, so that it continues
             // to point at the same track.
             PlaylistDatabase.SetIndex(Index - 1);
         }
     }));
 }
Beispiel #3
0
        public override async Task SetPlaylist(MusicItem song)
        {
            await TrySubmitDownload(song);

            PlaylistDatabase.SetPlaylist(AudioConversions.ToPlaylistTrack(song));
        }
Beispiel #4
0
 protected override Task SendSkipCommand(int index)
 {
     PlaylistDatabase.SetIndex(index);
     return(AsyncTasks.Noop());
 }
Beispiel #5
0
        public override async Task AddSongs(IEnumerable <MusicItem> songs)
        {
            await TrySubmitDownload(songs);

            PlaylistDatabase.AddAll(songs.Select(AudioConversions.ToPlaylistTrack).ToList());
        }
Beispiel #6
0
 public override Task <PlaylistInfo> LoadPlaylist()
 {
     return(TaskEx.FromResult(PlaylistDatabase.TracksAndIndex()));
 }
Beispiel #7
0
 public ResourceSearch(PlaylistDatabase database)
 {
     Database = database;
     Exchange(Build(database));
 }
Beispiel #8
0
 /// <summary>
 /// Implements the logic to get the previous AudioTrack instance.
 /// </summary>
 /// <remarks>
 /// The AudioTrack URI determines the source, which can be:
 /// (a) Isolated-storage file (Relative URI, represents path in the isolated storage)
 /// (b) HTTP URL (absolute URI)
 /// (c) MediaStreamSource (null)
 /// </remarks>
 /// <returns>an instance of AudioTrack, or null if previous track is not allowed</returns>
 private AudioTrack GetPreviousTrack()
 {
     return(ToAudioTrack(PlaylistDatabase.Previous()));
 }
Beispiel #9
0
 /// <summary>
 /// Implements the logic to get the next AudioTrack instance.
 /// In a playlist, the source can be from a file, a web request, etc.
 /// </summary>
 /// <remarks>
 /// The AudioTrack URI determines the source, which can be:
 /// (a) Isolated-storage file (Relative URI, represents path in the isolated storage)
 /// (b) HTTP URL (absolute URI)
 /// (c) MediaStreamSource (null)
 /// </remarks>
 /// <returns>an instance of AudioTrack, or null if the playback is completed</returns>
 private AudioTrack GetNextTrack()
 {
     return(ToAudioTrack(PlaylistDatabase.Next()));
 }