Skip to content

Commit

Permalink
Merge pull request #844 from janwiebe-jump/hotfix/issue-#841-nserror
Browse files Browse the repository at this point in the history
Avoid creating an NSError
  • Loading branch information
martijn00 authored Nov 23, 2021
2 parents cbb1b0a + a12b940 commit 7e84a4a
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions MediaManager/Platforms/Apple/Player/AppleMediaPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7e84a4a

Please sign in to comment.