public async static Task <string> CoverPlaylist(IPlaylistFile playlist) { var uriImage = playlist.Cover; StorageFile coverFile; try { coverFile = await StaticContent.CoversFolder.GetFileAsync($"VK{playlist.Id}Playlist.jpg"); } catch { if (config.SaveImage) { var task = Task.Run(async() => { coverFile = await StaticContent.CoversFolder.CreateFileAsync($"VK{playlist.Id}Playlist.jpg"); BackgroundDownloader downloader = new BackgroundDownloader(); DownloadOperation download = downloader.CreateDownload(new Uri(uriImage), coverFile); await download.StartAsync(); }); } return(uriImage); } return(coverFile.Path); }
public async static Task <PlaylistFile> ConvertToPlaylistFile(IPlaylistFile playlist) { string cover; if (playlist.Cover == "no") { cover = "ms-appx:///Assets/Images/playlist-placeholder.png"; } else { cover = await ImagesService.CoverPlaylist(playlist); } List <AudioFile> tracksFiles; if (playlist.IsAlbum) { tracksFiles = await MusicService.ConvertToAudioFile(playlist.Tracks, cover); } else { tracksFiles = await MusicService.ConvertToAudioFile(playlist.Tracks); } var playlistFile = new PlaylistFile() { Artist = playlist.Artist, Cover = cover, IsLocal = false, Tracks = playlist.Tracks, Id = playlist.Id, Name = playlist.Name, TracksFiles = tracksFiles, OnRequest = playlist.OnRequest, AccessKey = playlist.AccessKey, OwnerId = playlist.OwnerId, Genre = playlist.Genre, IsAlbum = playlist.IsAlbum, Year = playlist.Year, Description = playlist.Description }; return(playlistFile); }
public static PlaylistFile ConvertToPlaylistFile(this IPlaylistFile playlist) { string cover; if (playlist.Cover == "no") { cover = "playlist_placeholder"; } else { cover = ImagesService.CoverPlaylist(playlist); } List <AudioFile> tracksFiles; if (playlist.IsAlbum) { tracksFiles = MusicService.ConvertToAudioFile(playlist.Tracks, cover); } else { tracksFiles = MusicService.ConvertToAudioFile(playlist.Tracks); } var playlistFile = new PlaylistFile() { AccessKey = playlist.AccessKey, OwnerId = playlist.OwnerId, Artist = playlist.Artist, Cover = cover, IsLocal = false, Tracks = playlist.Tracks, Id = playlist.Id, Name = playlist.Name, TracksFiles = tracksFiles, Genre = playlist.Genre, IsAlbum = playlist.IsAlbum, Year = playlist.Year, Description = playlist.Description }; return(playlistFile); }
public static string CoverPlaylist(IPlaylistFile playlist) { return(CoverPlaylistById(playlist.Id, playlist.Cover)); }