/// <summary> /// Keeps the download progress properties of the music items up-to-date /// so that the progress can be displayed under each item in the UI. /// /// The music items in the library and the playlist do not point to the /// same object even if it's the same track so we need to update both places separately. /// </summary> /// <param name="transfer"></param> protected override void OnDownloadStatusUpdate(BackgroundTransferRequest transfer) { base.OnDownloadStatusUpdate(transfer); var path = FileUtilsBase.UnixSeparators(transfer.Tag.Substring(PhoneLocalLibrary.Instance.BaseMusicPath.Length)); var musicItem = MusicProvider.SearchItem(path); var isDownloading = transfer.TransferStatus == TransferStatus.Transferring; var bytesReceived = (ulong)transfer.BytesReceived; // updates track in the library if (musicItem != null) { MusicItem.SetDownloadStatus(musicItem, bytesReceived); musicItem.IsDownloading = isDownloading; } // updates the track in the playlist var playlistTracks = PimpViewModel.Instance.MusicPlayer.Playlist.Songs .Where(item => item.Song.Path == path) .ToList(); // beautiful!!! BasePlaylist.SetDownloadStatus(playlistTracks, bytesReceived); foreach (var item in playlistTracks) { item.Song.IsDownloading = isDownloading; } }
/// <summary> /// Resolves and returns the relative music path of the track the given file /// points to. The path is returned with Unix-style path separators. /// </summary> /// <param name="file"></param> /// <returns>the relative music path of the file with Unix-style path separators</returns> public static string MusicPath(IStorageFile file) { // music\Iron Maiden\... var path = AppLocalFolderFileUtils.LocalPath(file); // Iron Maiden/... return(FileUtilsBase.UnixSeparators(path.Substring(musicFolderName.Length + 1))); }
private async Task <List <MusicItem> > GetFolders(string root, string folder) { // todo clarify concepts; relative vs absolute var relativeFolder = root + folder; var ret = new List <MusicItem>(); var dirs = await FileUtil.ListFolderNames(relativeFolder); foreach (var dirName in dirs) { var path = FileUtilsBase.UnixSeparators(folder + dirName); ret.Add(new MusicItem() { Id = path, Name = dirName, IsDir = true, Path = path }); } return(ret); }
protected CoverService(FileUtilsBase fileUtils, string coverArtFolderPath) { this.fileUtils = fileUtils; this.coverArtFolderPath = coverArtFolderPath; httpClient = new HttpClient(); }
protected Task <Uri> UriFromPath(string filePath) { return(fileUtils.UriIfExistsAndPositiveSize(FileUtilsBase.UnixSeparators(filePath))); }
private static string Decode(string id) { return(FileUtilsBase.UnixSeparators(WebUtility.UrlDecode(id))); }