From 09b7f35bf01000de4dddf2b174d7dc845c4e5475 Mon Sep 17 00:00:00 2001 From: Martijn van Dijk Date: Fri, 26 Jul 2019 17:12:02 +0200 Subject: [PATCH] Add try catch back in --- .../Platforms/Android/Media/MediaExtractor.cs | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/MediaManager/Platforms/Android/Media/MediaExtractor.cs b/MediaManager/Platforms/Android/Media/MediaExtractor.cs index 8aed9f64..038f0041 100644 --- a/MediaManager/Platforms/Android/Media/MediaExtractor.cs +++ b/MediaManager/Platforms/Android/Media/MediaExtractor.cs @@ -20,20 +20,28 @@ public MediaExtractor() public override async Task ExtractMetadata(IMediaItem mediaItem) { - var metaRetriever = new MediaMetadataRetriever(); + try + { + var metaRetriever = new MediaMetadataRetriever(); + + switch (mediaItem.MediaLocation) + { + case MediaLocation.Embedded: + case MediaLocation.FileSystem: + await metaRetriever.SetDataSourceAsync(mediaItem.MediaUri); + break; + default: + await metaRetriever.SetDataSourceAsync(mediaItem.MediaUri, RequestHeaders); + break; + } - switch (mediaItem.MediaLocation) + return await ExtractMediaInfo(metaRetriever, mediaItem).ConfigureAwait(false); + } + catch { - case MediaLocation.Embedded: - case MediaLocation.FileSystem: - await metaRetriever.SetDataSourceAsync(mediaItem.MediaUri); - break; - default: - await metaRetriever.SetDataSourceAsync(mediaItem.MediaUri, RequestHeaders); - break; + } - - return await ExtractMediaInfo(metaRetriever, mediaItem).ConfigureAwait(false); + return mediaItem; } protected virtual async Task ExtractMediaInfo(MediaMetadataRetriever mediaMetadataRetriever, IMediaItem mediaItem)