Exemple #1
0
        /// <summary>
        /// Creates a MediaHistoryItem for the song we are playing and
        /// adds it to the history area of the Music + Videos Hub.
        /// </summary>
        private void AddToHistory()
        {
            if (_playingSong != null)
            {
                MediaHistoryItem historyItem = new MediaHistoryItem();
                historyItem.Title  = _playingSong.Name;
                historyItem.Source = "";

                // TODO: Use a more unique image here that better identifies
                // the history item as having come from this app.
                historyItem.ImageStream = _playingSong.Album.GetThumbnail();

                if (historyItem.ImageStream == null)
                {
                    // No album art found, use a generic place holder image.
                    StreamResourceInfo sri = Application.GetResourceStream(new Uri("AlbumThumbnailPlaceholder.png", UriKind.Relative));
                    historyItem.ImageStream = sri.Stream;
                }

                // If we get activated by the MediaHistoryItem we're creating here,
                // our NavigationContext will have a key-value pair ("playSong", "<Song Name>")
                // where <Song Name> is the Name property of the _playingSong object.
                historyItem.PlayerContext[_playSongKey] = _playingSong.Name;

                // Add our item to the MediaHistory area of the Music + Videos Hub.
                MediaHistory mediaHistory = MediaHistory.Instance;
                mediaHistory.WriteRecentPlay(historyItem);
            }
        }
Exemple #2
0
        private void UpdateHistory()
        {
            MediaHistoryItem   historyItem = new MediaHistoryItem();
            StreamResourceInfo sri         = Application.GetResourceStream(new Uri("NowPlayingIcon.jpg", UriKind.Relative));

            historyItem.ImageStream = sri.Stream;
            historyItem.Source      = "";
            historyItem.Title       = s.Name;
            historyItem.PlayerContext.Add(_key, songIndex.ToString());
            MediaHistory history = MediaHistory.Instance;

            history.WriteRecentPlay(historyItem);
        }
Exemple #3
0
 public static void CreateMediaHistory()
 {
     try
     {
         for (int i = 0; i < 30; i++)
         {
             //Create a snapshot of the page title
             StreamResourceInfo sri =
                 Application.GetResourceStream(new Uri(AppResources.ImageHistory, UriKind.RelativeOrAbsolute));
             var mediaHistoryItem = new MediaHistoryItem();
             //<hubTileImageStream> must be a valid ImageStream.
             mediaHistoryItem.ImageStream = sri.Stream;
             mediaHistoryItem.Source      = "";
             mediaHistoryItem.Title       = "STOP Music";
             mediaHistoryItem.PlayerContext.Add("STOP Music" + i, "STOP Music");
             MediaHistory mediaHistory = MediaHistory.Instance;
             mediaHistory.WriteRecentPlay(mediaHistoryItem);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }