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); }
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); } })); }
public override async Task SetPlaylist(MusicItem song) { await TrySubmitDownload(song); PlaylistDatabase.SetPlaylist(AudioConversions.ToPlaylistTrack(song)); }
protected override Task SendSkipCommand(int index) { PlaylistDatabase.SetIndex(index); return(AsyncTasks.Noop()); }
public override async Task AddSongs(IEnumerable <MusicItem> songs) { await TrySubmitDownload(songs); PlaylistDatabase.AddAll(songs.Select(AudioConversions.ToPlaylistTrack).ToList()); }
public override Task <PlaylistInfo> LoadPlaylist() { return(TaskEx.FromResult(PlaylistDatabase.TracksAndIndex())); }
public ResourceSearch(PlaylistDatabase database) { Database = database; Exchange(Build(database)); }
/// <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())); }
/// <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())); }