diff --git a/MediaManager/Platforms/Apple/Player/AppleMediaPlayer.cs b/MediaManager/Platforms/Apple/Player/AppleMediaPlayer.cs index 4adfba55..ac531baf 100644 --- a/MediaManager/Platforms/Apple/Player/AppleMediaPlayer.cs +++ b/MediaManager/Platforms/Apple/Player/AppleMediaPlayer.cs @@ -166,9 +166,22 @@ protected virtual void TimeControlStatusChanged(NSObservedChange obj) protected virtual void DidErrorOcurred(NSNotification obj) { - //TODO: Error should not be null after this or it will crash. - var error = Player?.CurrentItem?.Error ?? new NSError(); - MediaManager.OnMediaItemFailed(this, new MediaItemFailedEventArgs(MediaManager.Queue?.Current, new NSErrorException(error), error?.LocalizedDescription)); + Exception exception = null; + string message = null; + + var error = Player?.CurrentItem?.Error; + if(error != null) + { + exception = new NSErrorException(error); + message = error.LocalizedDescription; + } + else + { + message = obj?.ToString() ?? "MediaItem failed with unknown reason"; + exception = new ApplicationException(message); + } + + MediaManager.OnMediaItemFailed(this, new MediaItemFailedEventArgs(MediaManager.Queue?.Current, exception, message)); } protected virtual async void DidFinishPlaying(NSNotification obj)