From 10c27542e5ddc40939963e93bd0d854f431da850 Mon Sep 17 00:00:00 2001 From: Anonymous Raccoon <32224410+AnonymusRaccoon@users.noreply.github.com> Date: Sun, 10 Jun 2018 13:28:42 +0200 Subject: [PATCH] Solving some bugs. --- MusicApp/MusicApp.csproj | 4 +-- .../Resources/Portable Class/MusicPlayer.cs | 29 ++++--------------- MusicApp/Resources/Portable Class/Player.cs | 3 ++ MusicApp/Resources/Portable Class/Playlist.cs | 4 +-- MusicApp/packages.config | 2 +- 5 files changed, 13 insertions(+), 29 deletions(-) diff --git a/MusicApp/MusicApp.csproj b/MusicApp/MusicApp.csproj index efb8470..bddb8a6 100644 --- a/MusicApp/MusicApp.csproj +++ b/MusicApp/MusicApp.csproj @@ -228,8 +228,8 @@ ..\packages\Xamarin.GooglePlayServices.Tasks.60.1142.1\lib\MonoAndroid80\Xamarin.GooglePlayServices.Tasks.dll - - ..\packages\YoutubeExplode.4.2.5\lib\netstandard2.0\YoutubeExplode.dll + + ..\packages\YoutubeExplode.4.2.7\lib\netstandard2.0\YoutubeExplode.dll diff --git a/MusicApp/Resources/Portable Class/MusicPlayer.cs b/MusicApp/Resources/Portable Class/MusicPlayer.cs index 3d6f79e..e99d84b 100644 --- a/MusicApp/Resources/Portable Class/MusicPlayer.cs +++ b/MusicApp/Resources/Portable Class/MusicPlayer.cs @@ -180,10 +180,10 @@ namespace MusicApp.Resources.Portable_Class if(Build.VERSION.SdkInt >= BuildVersionCodes.O) { AudioFocusRequestClass focusRequest = new AudioFocusRequestClass.Builder(AudioFocus.Gain) - .SetAudioAttributes(attributes) - .SetAcceptsDelayedFocusGain(true) - .SetOnAudioFocusChangeListener(this) - .Build(); + .SetAudioAttributes(attributes) + .SetAcceptsDelayedFocusGain(true) + .SetOnAudioFocusChangeListener(this) + .Build(); AudioFocusRequest audioFocus = audioManager.RequestAudioFocus(focusRequest); if (audioFocus != AudioFocusRequest.Granted) @@ -228,29 +228,11 @@ namespace MusicApp.Resources.Portable_Class CreateNotification(song.GetName(), song.GetArtist(), song.GetAlbumArt(), song.GetAlbum()); - if(addToQueue) + if (addToQueue) AddToQueue(song); Player.instance?.RefreshPlayer(); ParseNextSong(); - - //CoordinatorLayout smallPlayer = MainActivity.instance.FindViewById(Resource.Id.smallPlayer); - //smallPlayer.FindViewById(Resource.Id.spTitle).Text = song.GetName(); - //smallPlayer.FindViewById(Resource.Id.spArtist).Text = song.GetArtist(); - //smallPlayer.FindViewById(Resource.Id.spPlay).SetImageResource(Resource.Drawable.ic_pause_black_24dp); - //ImageView art = smallPlayer.FindViewById(Resource.Id.spArt); - - //if (!song.IsYt) - //{ - // var songCover = Uri.Parse("content://media/external/audio/albumart"); - // var nextAlbumArtUri = ContentUris.WithAppendedId(songCover, song.GetAlbumArt()); - - // Picasso.With(Application.Context).Load(nextAlbumArtUri).Placeholder(Resource.Drawable.MusicIcon).Resize(400, 400).CenterCrop().Into(art); - //} - //else - //{ - // Picasso.With(Application.Context).Load(song.GetAlbum()).Placeholder(Resource.Drawable.MusicIcon).Resize(400, 400).CenterCrop().Into(art); - //} } public void Play(Song song, bool addToQueue = true, long progress = -1) @@ -897,7 +879,6 @@ namespace MusicApp.Resources.Portable_Class private void SleepPause() { - //Pause(); Stop(); } diff --git a/MusicApp/Resources/Portable Class/Player.cs b/MusicApp/Resources/Portable Class/Player.cs index c3a44ec..099726f 100644 --- a/MusicApp/Resources/Portable Class/Player.cs +++ b/MusicApp/Resources/Portable Class/Player.cs @@ -210,6 +210,9 @@ namespace MusicApp.Resources.Portable_Class while (MusicPlayer.CurrentID() == -1) await Task.Delay(100); + if (playerView == null) + return; + TextView title = playerView.FindViewById(Resource.Id.playerTitle); TextView artist = playerView.FindViewById(Resource.Id.playerArtist); imgView = playerView.FindViewById(Resource.Id.playerAlbum); diff --git a/MusicApp/Resources/Portable Class/Playlist.cs b/MusicApp/Resources/Portable Class/Playlist.cs index 4a33684..986660b 100644 --- a/MusicApp/Resources/Portable Class/Playlist.cs +++ b/MusicApp/Resources/Portable Class/Playlist.cs @@ -411,12 +411,12 @@ namespace MusicApp.Resources.Portable_Class Browse.Play(songs[0]); songs.RemoveAt(0); songs.Reverse(); - + while (MusicPlayer.instance == null) await Task.Delay(10); - foreach(Song song in songs) + foreach (Song song in songs) { MusicPlayer.instance.AddToQueue(song); } diff --git a/MusicApp/packages.config b/MusicApp/packages.config index bd9dcb6..965a418 100644 --- a/MusicApp/packages.config +++ b/MusicApp/packages.config @@ -95,5 +95,5 @@ - + \ No newline at end of file