Exemplo n.º 1
0
 public DetailsPage(GoogleMusicSong selectedSong)
 {
     this.InitializeComponent();
     this.DataContext = selectedSong;
     albumListView.ItemsSource = App.googleAPI.Tracks.GroupBy(song => song.AlbumArtist).Select(song => song.First()).Where(song => song.AlbumArtist == selectedSong.AlbumArtist);
     songListView.ItemsSource = App.googleAPI.Tracks.Where(song => song.AlbumArtist == selectedSong.AlbumArtist && song.Album == selectedSong.Album).OrderBy(song => song.Track);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Modify a songs meta data
        /// </summary>
        /// <param name="song">Song to be changed</param>
        /// <param name="metaKey">Key to change, ie: rating</param>
        /// <param name="metaValue">Value of key</param>
        /// <returns></returns>
        public async Task <String> ModifySong(GoogleMusicSong song, String metaKey, object metaValue)
        {
            // puke
            String      jsonString = "{\"entries\":[{\"id\" : \"" + song.ID + "\", \"" + metaKey + "\":" + "\"" + metaValue + "\"}]}";
            HttpContent content    = new FormUrlEncodedContent(new[]
            {
                new KeyValuePair <string, string>("json", jsonString),
            });

            return(await client.POST(new Uri("https://play.google.com/music/services/modifyentries"), content));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get song share url
        /// </summary>
        /// <param name="song">song to share</param>
        /// <returns></returns>
        public async Task <String> GetShareableURL(GoogleMusicSong song)
        {
            // Not all songs can be shared, licensing prolly
            if (song.StoreID == null)
            {
                return(null);
            }

            String jsonString = "{\"trackId\":\"" + song.StoreID + "\"}";

            HttpContent content = new FormUrlEncodedContent(new[]
            {
                new KeyValuePair <string, string>("json", jsonString),
            });


            GoogleMusicSongUrl url = await client.POST <GoogleMusicSongUrl>(new Uri("https://play.google.com/music/services/shareprepurchasepreview"), content);

            return(url.URL);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Increment a song's playcount by 1
 /// </summary>
 /// <param name="song">Song to inc playcount</param>
 public async void IncrementPlaycount(GoogleMusicSong song)
 {
     await ModifySong(song, "playCount", song.Playcount + 1);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Thumbs down a song
 /// </summary>
 /// <param name="song">Song to hate</param>
 public async void DislikeSong(GoogleMusicSong song)
 {
     await ModifySong(song, "rating", 0);
 }
Exemplo n.º 6
0
        /// <summary>
        /// Modify a songs meta data
        /// </summary>
        /// <param name="song">Song to be changed</param>
        /// <param name="metaKey">Key to change, ie: rating</param>
        /// <param name="metaValue">Value of key</param>
        /// <returns></returns>
        public async Task<String> ModifySong(GoogleMusicSong song, String metaKey, object metaValue)
        {
            // puke
            String jsonString = "{\"entries\":[{\"id\" : \"" + song.ID + "\", \"" + metaKey +"\":"+"\"" + metaValue + "\"}]}";
            HttpContent content = new FormUrlEncodedContent(new[]
            {
                new KeyValuePair<string, string>("json", jsonString),
            });

            return await client.POST(new Uri("https://play.google.com/music/services/modifyentries"), content);
        }
Exemplo n.º 7
0
 public void showDetailFlyout(GoogleMusicSong song)
 {
     Flyout flyout = new Flyout();
     flyout.FlyoutWidth = (int) Window.Current.Bounds.Width / 2;
     flyout.FlyoutHeight = (int)(Window.Current.Bounds.Height * .8);
     flyout.FlyoutLeft = (int)Window.Current.Bounds.Width / 4;
     flyout.FlyoutTop = (int)(Window.Current.Bounds.Height / 10);
     flyout.ShowFlyout(new DetailsPage(song));
 }
Exemplo n.º 8
0
 public List<GoogleMusicSong> GetArtist(GoogleMusicSong song)
 {
     return songs.Where(s => s.Artist == song.Artist).OrderBy(s => s.AlbumArtist).ThenBy(s => s.Track).ToList();
 }
Exemplo n.º 9
0
        public void PlaySong(GoogleMusicSong song)
        {
            int index = queue.IndexOf(song);

            if (index < 0)
            {
                queue.Insert(currentIndex + 1, song);
                currentIndex++;
            }
            else
            {
                currentIndex = index;
            }

            Play();
        }
Exemplo n.º 10
0
 /// <summary>
 /// Thumbs down a song
 /// </summary>
 /// <param name="song">Song to hate</param>
 public async void DislikeSong(GoogleMusicSong song)
 {
     await ModifySong(song, "rating", 0);
 }
Exemplo n.º 11
0
 public void AddSong(GoogleMusicSong song)
 {
     queue.Add(song);
 }
Exemplo n.º 12
0
 public void Dequeue(GoogleMusicSong song)
 {
     queue.Remove(song);
 }
Exemplo n.º 13
0
 public void Enqueue(GoogleMusicSong song)
 {
     queue.Add(song);
 }
Exemplo n.º 14
0
 /// <summary>
 /// Increment a song's playcount by 1
 /// </summary>
 /// <param name="song">Song to inc playcount</param>
 public async void IncrementPlaycount(GoogleMusicSong song)
 {
     await ModifySong(song, "playCount", song.Playcount + 1);
 }
Exemplo n.º 15
0
        /// <summary>
        /// Get song share url
        /// </summary>
        /// <param name="song">song to share</param>
        /// <returns></returns>
        public async Task<String> GetShareableURL(GoogleMusicSong song)
        {
            // Not all songs can be shared, licensing prolly
            if (song.StoreID == null)
                return null;

            String jsonString = "{\"trackId\":\"" + song.StoreID + "\"}";

            HttpContent content = new FormUrlEncodedContent(new[]
            {
                new KeyValuePair<string, string>("json", jsonString),
            });


            GoogleMusicSongUrl url = await client.POST<GoogleMusicSongUrl>(new Uri("https://play.google.com/music/services/shareprepurchasepreview"), content);
            return url.URL;
        }
Exemplo n.º 16
0
        /// <summary>
        /// Gets the stream URL from a given song
        /// </summary>
        /// <param name="song">Song to stream</param>
        /// <returns></returns>
        public async Task<String> GetStreamURL(GoogleMusicSong song)
        {
            Uri reqUrl = null;
            // Looks like it's a preview song
            if (song.Preview != null)
            {
                reqUrl = new Uri(String.Format("https://play.google.com/music/playpreview?u=0&mode=streaming&preview={0}&tid={1}&pt=e",
                    song.Preview.PreviewToken, song.Preview.TrackID));
            }
            // Shared song
            else if (song.Share != null)
            {
                reqUrl = new Uri(String.Format("https://play.google.com/music/playpreview?u=0&mode=streaming&preview={0}&tid={1}&postid={2}pt=e",
                    song.Preview.PreviewToken, song.Preview.TrackID, song.Share.PostID));
            }
            // Normal song
            else
            {
                reqUrl = new Uri(String.Format("https://play.google.com/music/play?u=0&songid={0}", song.ID));
            }

            GoogleMusicSongUrl songUrl = null;
            try{
               songUrl = await client.GET<GoogleMusicSongUrl>(reqUrl);
            }
            catch{

            }

            return (songUrl != null) ? songUrl.URL : String.Empty;
        }
Exemplo n.º 17
0
 public void RemoveSong(GoogleMusicSong song)
 {
     queue.Remove(song);
 }