/// <summary> /// Updates the tile. Called when the app is initialized and whenever the track changes. /// /// </summary> /// <param name="track">the track, which may be null</param> /// <param name="init">true if this method is called because the app is being initialized, false otherwise</param> /// <returns></returns> public async Task UpdateTileAndBackground(MusicItem track, bool init = false) { try { if (track != null) { await Update(track); var maybeCover = await Covers.TryGetCover(track); if (maybeCover != null) { await SetBackground(maybeCover); } } else { await UpdateNoTrack(); if (init) { var uri = await SetRandomBackground(); //if(uri == null) { // await SetBackground(DefaultBackgroundUri); //} } } } catch (Exception) { // suppresses the exception intentionally, what is the user supposed to do anyway if this fails? // it fails occasionally with some absurd COM Exception message //MessagingService.Instance.Send("Failed to update tile or unable to send toast. " + e.Message); } }
protected async Task <Uri> GetCoverUriOrDefault(MusicItem track) { mutex.WaitOne(); Uri maybeCover = null; try { maybeCover = await Covers.TryGetCover(track); } finally { mutex.ReleaseMutex(); } return(maybeCover != null?PhoneTileUtil.TileUri(maybeCover) : defaultTileUri); }
/// <summary> /// Sends a toast notification displaying metadata of the given track. /// </summary> /// <param name="track">track to display in toast notification</param> /// <returns></returns> public override async Task Update(MusicItem track) { Uri maybeCover = await Covers.TryGetCover(track); if (maybeCover != null) { await SetBackground(maybeCover); } var xml = await SetXmlContent(track, maybeCover); SetSilent(xml); Show(xml); }
protected async Task <Uri> GetCoverUriOrDefault(MusicItem track) { var maybeUri = await Covers.TryGetCover(track); return(maybeUri != null ? maybeUri : DefaultImageUri); }