From bca6696f32d23f79c25cf48e70704cc1c69c99bb Mon Sep 17 00:00:00 2001 From: jmartine2 Date: Wed, 12 Oct 2016 10:33:40 -0700 Subject: [PATCH] Fixed WifiLock under-locked exception. Fixed OutOfMemoryError with large album art. --- .../MediaPlayerService.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/MediaManager/Plugin.MediaManager.Android/MediaPlayerService.cs b/MediaManager/Plugin.MediaManager.Android/MediaPlayerService.cs index f7f82b22..74ae511c 100644 --- a/MediaManager/Plugin.MediaManager.Android/MediaPlayerService.cs +++ b/MediaManager/Plugin.MediaManager.Android/MediaPlayerService.cs @@ -446,7 +446,16 @@ public async Task Play() Cover = await BitmapFactory.DecodeResourceAsync(Resources, Resource.Drawable.ButtonStar); } else - Cover = await BitmapFactory.DecodeByteArrayAsync(imageByteArray, 0, imageByteArray.Length); + { + try + { + Cover = await BitmapFactory.DecodeByteArrayAsync(imageByteArray, 0, imageByteArray.Length); + } + catch (Java.Lang.OutOfMemoryError) + { + Cover = null; + } + } StartedPlayback = true; } catch (Exception ex) @@ -934,7 +943,13 @@ private void ReleaseWifiLock() if (wifiLock == null || !wifiLock.IsHeld) return; - wifiLock.Release(); + try + { + wifiLock.Release(); + } + catch (Java.Lang.RuntimeException) + { } + wifiLock = null; }