Exemple #1
0
        public static async void UpdateLiveTile()
        {
            try
            {
                if (LocalConfiguration.LiveTileDesign == LiveTileDesign.Disabled)
                {
                    ClearLiveTile();
                    return;
                }

                var artistPhoto = await SongImageProvider.GetArtistArt(PlayStatusTracker.LastPlayStatus.ArtistId);

                var albumPhoto = await SongImageProvider.GetAlbumArt(PlayStatusTracker.LastPlayStatus.AlbumId);

                var template = GetLiveTileTemplate(LocalConfiguration.LiveTileDesign)
                               .Replace("{albumName}", WebUtility.HtmlEncode(PlayStatusTracker.LastPlayStatus.AlbumName))
                               .Replace("{artistName}", WebUtility.HtmlEncode(PlayStatusTracker.LastPlayStatus.ArtistName))
                               .Replace("{songName}", WebUtility.HtmlEncode(PlayStatusTracker.LastPlayStatus.SongName))
                               .Replace("{artistPhoto}", WebUtility.HtmlEncode(artistPhoto))
                               .Replace("{albumPhoto}", WebUtility.HtmlEncode(albumPhoto));

                UpdateTileWithTemplate(template);

                logger.Info("Live tile updated.");
            }
            catch (Exception ex)
            {
                logger.Warn("UpdateLiveTile failed: " + ex.ToString());
            }
        }
Exemple #2
0
        public static async Task <TileImageCollection> GetTileImages(string pageUrl)
        {
            try
            {
                if (pageUrl.ToLower().StartsWith("https://open.spotify.com/playlist/"))
                {
                    string playlistId = pageUrl.Substring("https://open.spotify.com/playlist/".Length);
                    if (playlistId.Contains('/'))
                    {
                        playlistId = playlistId.Substring(0, playlistId.IndexOf('/') - 1);
                    }

                    var image = await ImageSaveHelper.GetAndSaveTileOriginalImage(await SongImageProvider.GetPlaylistArt(playlistId));

                    var tileImages = await CreateTileImages(image);

                    await(await StorageFile.GetFileFromApplicationUriAsync(image)).DeleteAsync();

                    return(tileImages);
                }
                else if (pageUrl.ToLower().StartsWith("https://open.spotify.com/artist/"))
                {
                    string artistId = pageUrl.Substring("https://open.spotify.com/artist/".Length);
                    if (artistId.Contains('/'))
                    {
                        artistId = artistId.Substring(0, artistId.IndexOf('/') - 1);
                    }

                    var image = await ImageSaveHelper.GetAndSaveTileOriginalImage(await SongImageProvider.GetArtistArt(artistId));

                    var tileImages = await CreateTileImages(image);

                    await(await StorageFile.GetFileFromApplicationUriAsync(image)).DeleteAsync();

                    return(tileImages);
                }
                else if (pageUrl.ToLower().StartsWith("https://open.spotify.com/album/"))
                {
                    string albumId = pageUrl.Substring("https://open.spotify.com/album/".Length);
                    if (albumId.Contains('/'))
                    {
                        albumId = albumId.Substring(0, albumId.IndexOf('/') - 1);
                    }

                    var image = await ImageSaveHelper.GetAndSaveTileOriginalImage(await SongImageProvider.GetAlbumArt(albumId));

                    var tileImages = await CreateTileImages(image);

                    await(await StorageFile.GetFileFromApplicationUriAsync(image)).DeleteAsync();

                    return(tileImages);
                }
            }
            catch (Exception ex)
            {
                logger.Info("GetTileImage failed: " + ex.ToString());
            }

            return(null);
        }