예제 #1
0
        private async Task <bool> DownloadArtworkAsync(string uri, string path)
        {
            if (string.IsNullOrEmpty(uri) || !uri.StartsWith("http"))
            {
                return(false);
            }

            // make sure it doesn't exists (when track is deleted, artwork won't be deleted until next startup)
            if (!await _storageUtility.ExistsAsync(path))
            {
                using (var response = await uri.ToUri().GetAsync())
                    if (response.IsSuccessStatusCode)
                    {
                        using (var stream = await response.Content.ReadAsStreamAsync())
                        {
                            await _storageUtility.WriteStreamAsync(path, stream);

                            return(true);
                        }
                    }
            }
            return(false);
        }