Esempio n. 1
0
        private async void LoadTrack(SoundCloudTrack currentTrack)
        {
            try
            {
                //Stop player, set new stream uri and play track
                shell.mPlayer.Stop();
                Uri streamUri = new Uri(currentTrack.stream_url + "?client_id=" + App.SoundCloudClientId);
                shell.mPlayer.Source = streamUri;
                shell.mPlayer.Play();

                //Change album art
                string albumartImage = Convert.ToString(currentTrack.artwork_url);
                if (string.IsNullOrWhiteSpace(albumartImage))
                {
                    albumartImage = @"ms-appx:///Assets\Albumart.png";
                }
                else
                {
                    albumartImage = albumartImage.Replace("-large", "-t500x500");
                }

                albumrtImage.ImageSource = new BitmapImage(new Uri(albumartImage));

                //Change Title and User name
                txtSongTitle.Text  = currentTrack.title;
                txtAlbumTitle.Text = Convert.ToString(currentTrack.user.username);
            }
            catch (Exception ex)
            {
                MessageDialog showMessgae = new MessageDialog("Something went wrong. Please try again. Error Details : " + ex.Message);
                await showMessgae.ShowAsync();
            }
        }
        private async void LoadTrack(SoundCloudTrack currentTrack)
        {
            try
            {
                //Stop player, set new stream uri and play track
                shell.mPlayer.Stop();
                Uri streamUri = new Uri(currentTrack.stream_url + "?client_id=" + App.SoundCloudClientId);
                shell.mPlayer.Source = streamUri;
                shell.mPlayer.Play();

                //Change album art
                string albumartImage = Convert.ToString(currentTrack.artwork_url);
                if (string.IsNullOrWhiteSpace(albumartImage))
                {
                    albumartImage = @"ms-appx:///Assets\Albumart.png";

                }
                else
                {
                    albumartImage = albumartImage.Replace("-large", "-t500x500");
                }

                albumrtImage.ImageSource = new BitmapImage(new Uri(albumartImage));

                //Change Title and User name
                txtSongTitle.Text = currentTrack.title;
                txtAlbumTitle.Text = Convert.ToString(currentTrack.user.username);

            }
            catch (Exception ex)
            {
                MessageDialog showMessgae = new MessageDialog("Something went wrong. Please try again. Error Details : " + ex.Message);
                await showMessgae.ShowAsync();
            }
        }
Esempio n. 3
0
 private void NowPlaying_Loaded(object sender, RoutedEventArgs e)
 {
     if (App.nowPlaying.Count > 0)
     {
         SoundCloudTrack currentTrack = App.nowPlaying[App.nowplayingTrackId];
         LoadTrack(currentTrack);
     }
 }
Esempio n. 4
0
        private void btnPrev_Click(object sender, RoutedEventArgs e)
        {
            App.nowplayingTrackId -= 1;
            if (App.nowplayingTrackId < 0)
            {
                App.nowplayingTrackId = App.nowPlaying.Count - 1;
            }

            SoundCloudTrack currentTrack = App.nowPlaying[App.nowplayingTrackId];

            LoadTrack(currentTrack);
        }
Esempio n. 5
0
        private void btnNext_Click(object sender, RoutedEventArgs e)
        {
            App.nowplayingTrackId += 1;
            if (App.nowplayingTrackId >= App.nowPlaying.Count)
            {
                App.nowplayingTrackId = 0;
            }

            SoundCloudTrack currentTrack = App.nowPlaying[App.nowplayingTrackId];

            LoadTrack(currentTrack);
        }