예제 #1
0
        private async Task PlaySong()
        {
            switch (CurrentSong.Source)
            {
            case "Spotify":
                SpotifyApiManager.PlayTrack(CurrentSong.Uri);
                break;

            case "Library":
                var mediaFile = new MediaFile
                {
                    Url      = "file://" + CurrentSong.Uri,
                    Metadata = new MediaFileMetadata {
                        AlbumArt = CurrentSong.ImageUrl
                    },
                    Type         = MediaFileType.Audio,
                    Availability = ResourceAvailability.Local
                };
                await CrossMediaManager.Current.Play(mediaFile);

                break;

            default:
                break;
            }
        }
예제 #2
0
        private async Task Search(string query)
        {
            if (User.IsSpotifyAuthenticated && !string.IsNullOrEmpty(query))
            {
                using (_tokenSource = new CancellationTokenSource())
                {
                    try
                    {
                        IsBusy = true;
                        await Task.Delay(TimeSpan.FromSeconds(1), _tokenSource.Token);

                        var searchResults = await SpotifyApiManager.GetSearchResults(query, _tokenSource.Token);

                        MessagingCenter.Send(this, "Search", searchResults);
                    }
                    catch (TaskCanceledException)
                    {
                    }
                    finally
                    {
                        IsBusy = false;
                    }
                }
            }

            //if (string.IsNullOrWhiteSpace(query))
            //{
            //    IsSearchBoxVisible = false;
            //}
            //else
            //{
            //    IsSearchBoxVisible = true;
            //}
        }
예제 #3
0
 private async Task ResumeSong()
 {
     if (CurrentSong.Source.Equals("Spotify"))
     {
         SpotifyApiManager.ResumeTrack();
     }
     else if (CurrentSong.Source.Equals("Library"))
     {
         await CrossMediaManager.Current.Play();
     }
 }
예제 #4
0
        private async void UpdateUI()
        {
            using (_tokenSource = new CancellationTokenSource())
            {
                try
                {
                    IsBusy = true;
                    await Task.Delay(TimeSpan.FromSeconds(1), _tokenSource.Token);

                    var _playlists = await SpotifyApiManager.GetUserPlaylistsAsync(_tokenSource.Token);

                    Playlists = _playlists.Select(x => new Playlist {
                        Name = x.Name, ImageUrl = x.Images[0].Url, NumberOfTracks = x.Tracks.Total, OwnerId = Uri.EscapeDataString(x.Owner.Id), Id = Uri.EscapeDataString(x.Id)
                    }).ToList();
                }
                catch (TaskCanceledException)
                {
                }
                finally
                {
                    IsBusy = false;
                }
            }
        }
예제 #5
0
        private async void UpdateUI()
        {
            using (_tokenSource = new CancellationTokenSource())
            {
                try
                {
                    IsBusy = true;
                    await Task.Delay(TimeSpan.FromSeconds(1), _tokenSource.Token);

                    var _songs = await SpotifyApiManager.GetSavedTracks(_tokenSource.Token);

                    Songs = _songs.Select(x => new Song {
                        Title = x.Name, Uri = x.Uri, Artist = x.Artists[0].Name, ImageUrl = x.Album.Images[0].Url, DurationInSeconds = x.DurationMs / 1000, Source = "Spotify"
                    }).ToList();
                }
                catch (TaskCanceledException)
                {
                }
                finally
                {
                    IsBusy = false;
                }
            }
        }
예제 #6
0
        private void AddSongToQueue(Song song)
        {
            song.AddToQueueCommand.Execute(null);

            SpotifyApiManager.AddSongToQueue(song, this);
        }
예제 #7
0
 private void AddSongToQueue(Song s)
 {
     SpotifyApiManager.AddSongToQueue(s, this);
 }