コード例 #1
0
ファイル: DetailsPage.xaml.cs プロジェクト: grantamos/decibel
 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);
 }
コード例 #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));
        }
コード例 #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);
        }
コード例 #4
0
ファイル: API.cs プロジェクト: grantamos/decibel
 /// <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);
 }
コード例 #5
0
ファイル: API.cs プロジェクト: grantamos/decibel
 /// <summary>
 /// Thumbs down a song
 /// </summary>
 /// <param name="song">Song to hate</param>
 public async void DislikeSong(GoogleMusicSong song)
 {
     await ModifySong(song, "rating", 0);
 }
コード例 #6
0
ファイル: API.cs プロジェクト: grantamos/decibel
        /// <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);
        }
コード例 #7
0
ファイル: MainPage.xaml.cs プロジェクト: grantamos/decibel
 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));
 }
コード例 #8
0
ファイル: Collection.cs プロジェクト: grantamos/decibel
 public List<GoogleMusicSong> GetArtist(GoogleMusicSong song)
 {
     return songs.Where(s => s.Artist == song.Artist).OrderBy(s => s.AlbumArtist).ThenBy(s => s.Track).ToList();
 }
コード例 #9
0
ファイル: SongQueue.cs プロジェクト: grantamos/decibel
        public void PlaySong(GoogleMusicSong song)
        {
            int index = queue.IndexOf(song);

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

            Play();
        }
コード例 #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);
 }
コード例 #11
0
ファイル: SongQueue.cs プロジェクト: grantamos/decibel
 public void AddSong(GoogleMusicSong song)
 {
     queue.Add(song);
 }
コード例 #12
0
ファイル: Library.cs プロジェクト: grantamos/decibel
 public void Dequeue(GoogleMusicSong song)
 {
     queue.Remove(song);
 }
コード例 #13
0
ファイル: Library.cs プロジェクト: grantamos/decibel
 public void Enqueue(GoogleMusicSong song)
 {
     queue.Add(song);
 }
コード例 #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);
 }
コード例 #15
0
ファイル: API.cs プロジェクト: grantamos/decibel
        /// <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;
        }
コード例 #16
0
ファイル: API.cs プロジェクト: grantamos/decibel
        /// <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;
        }
コード例 #17
0
ファイル: SongQueue.cs プロジェクト: grantamos/decibel
 public void RemoveSong(GoogleMusicSong song)
 {
     queue.Remove(song);
 }