Are there any possibilities to handle errors from AVPlayer ?

imixalimixal Member ✭✭

I'm working with AVPlayer and easily handling errors from AVPlayerItem. But I need to get notifications when AVPlayer has something in the Error Property. According samples in the Internet, there is option to override ObserveValue method and add several notification in the Notification center.
But in my case, I don't inherit IosViewController and use my custom output for viewing.

Is there any option to subscribe to Error property in AVPlayer?

Answers

  • ColeXColeX Member, Xamarin Team Xamurai
     avPlayer.AddObserver("error", NSKeyValueObservingOptions.New, (NSObservedChange change) => {
                  //handle here 
            });
    

    Does this code not work ?

  • imixalimixal Member ✭✭

    @ColeX said:

     avPlayer.AddObserver("error", NSKeyValueObservingOptions.New, (NSObservedChange change) => {
                  //handle here 
            });
    

    Does this code not work ?

    It doesn't work

  • ColeXColeX Member, Xamarin Team Xamurai

    Check the article : How to handle error which was detected by AVPlayer that get video content from HLS.

    It provides the steps of

    • Watch AVPlayer.status and AVPlayerItem.status
    • Listen to these notifications
      1. NSNotification.Name.AVPlayerItemFailedToPlayToEndTime
      2. NSNotification.Name.AVPlayerItemNewErrorLogEntry
Sign In or Register to comment.