Example #1
0
        /// <summary>
        ///     Called when the current playing item changes
        /// </summary>
        private async void CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            await DispatcherHelper.ExecuteOnUIThreadAsync(async() =>
            {
                // Only perform the following actions if there is a new track
                if (args.NewItem == null)
                {
                    return;
                }

                if (Service.CurrentTrack == null)
                {
                    return;
                }

                // Set the pin button text
                PinButtonText = TileService.Instance.DoesTileExist("Track_" + Service.CurrentTrack.Id) ? "Unpin" : "Pin";

                // Set the like button text
                LikeButtonText = await SoundByteService.Instance.ExistsAsync("/me/favorites/" + Service.CurrentTrack.Id)
                    ? "Unlike"
                    : "Like";

                // Set the repost button text
                RepostButtonText =
                    await SoundByteService.Instance.ExistsAsync("/e1/me/track_reposts/" + Service.CurrentTrack.Id)
                        ? "Unpost"
                        : "Repost";

                // Reload all the comments
                CommentItems.RefreshItems();
            });
        }
Example #2
0
        /// <summary>
        ///     Called when the current playing item changes
        /// </summary>
        private async void CurrentItemChanged(MediaPlaybackList sender, CurrentMediaPlaybackItemChangedEventArgs args)
        {
            await DispatcherHelper.ExecuteOnUIThreadAsync(async() =>
            {
                // Only perform the following actions if there is a new track
                if (args.NewItem == null)
                {
                    return;
                }

                if (Service.CurrentTrack == null)
                {
                    return;
                }

                var overlay = App.CurrentFrame.FindName("VideoOverlay") as MediaElement;

                if (overlay != null)
                {
                    if (Service.CurrentTrack.ServiceType == ServiceType.YouTube)
                    {
                        overlay.Source = new Uri(Service.CurrentTrack.VideoStreamUrl);
                        overlay.Play();
                    }
                    else
                    {
                        overlay.Opacity = 0;
                        overlay.Pause();
                        overlay.Source = null;
                    }
                }

                // Set the pin button text
                PinButtonText = TileHelper.IsTilePinned("Track_" + Service.CurrentTrack.Id) ? "Unpin" : "Pin";

                // Set the like button text
                LikeButtonText = await SoundByteV3Service.Current.ExistsAsync(ServiceType.SoundCloud, "/me/favorites/" + Service.CurrentTrack.Id)
                    ? "Unlike"
                    : "Like";

                // Set the repost button text
                RepostButtonText =
                    await SoundByteV3Service.Current.ExistsAsync(ServiceType.SoundCloud, "/e1/me/track_reposts/" + Service.CurrentTrack.Id)
                        ? "Unpost"
                        : "Repost";

                // Reload all the comments
                CommentItems.RefreshItems();
            });
        }