From 13668912f4dde8d28a5d40ecf607db4707036519 Mon Sep 17 00:00:00 2001 From: Anonymus Raccoon <32224410+AnonymusRaccoon@users.noreply.github.com> Date: Tue, 25 Jun 2019 18:32:58 +0200 Subject: [PATCH] Solving a bug with files that were removed. --- Opus/Code/Api/Services/MusicPlayer.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Opus/Code/Api/Services/MusicPlayer.cs b/Opus/Code/Api/Services/MusicPlayer.cs index f242262..c147e4f 100644 --- a/Opus/Code/Api/Services/MusicPlayer.cs +++ b/Opus/Code/Api/Services/MusicPlayer.cs @@ -274,6 +274,7 @@ namespace Opus.Api.Services IExtractorsFactory extractorFactory = new DefaultExtractorsFactory(); Handler handler = new Handler(); + Console.WriteLine("&Preparing exoplay, path: " + song.Path); IMediaSource mediaSource; if (song.IsLiveStream) mediaSource = new HlsMediaSource(Uri.Parse(song.Path), dataSourceFactory, handler, null); @@ -1156,7 +1157,7 @@ namespace Opus.Api.Services public async static Task Duration() { - if(!UseCastPlayer) + if (!UseCastPlayer) return player == null ? (await GetItem()).Duration : (int)player.Duration; else return RemotePlayer == null ? (await GetItem()).Duration : (int)RemotePlayer.StreamDuration; @@ -1170,12 +1171,16 @@ namespace Opus.Api.Services Song song = await GetItem(); if (song.IsYt && song.IsParsed != true) await new SongParser().ParseSong(song); - else if(!song.IsYt) + else if (!song.IsYt) { - MediaMetadataRetriever meta = new MediaMetadataRetriever(); - await meta.SetDataSourceAsync(song.Path); - song.Duration = int.Parse(meta.ExtractMetadata(MetadataKey.Duration)); - meta.Release(); + try + { + MediaMetadataRetriever meta = new MediaMetadataRetriever(); + await meta.SetDataSourceAsync(song.Path); + song.Duration = int.Parse(meta.ExtractMetadata(MetadataKey.Duration)); + meta.Release(); + } + catch (Java.IO.FileNotFoundException) { } } return song.Duration;