Brad Dean

Troubleshooting AVPlayer With Xamarin On iOS

When you’re using AVPlayer with Xamarin one of the difficulties can be troubleshooting. There’s an easy way to get error notification from AVPlayer that isn’t mentioned in the Xamarin documentation.

You probably already have something similiar to this line:

_playerItem.AddObserver( this, "status", NSKeyValueObservingOptions.Initial | NSKeyValueObservingOptions.New, IntPtr.Zero );

To get notification of errors as well, just add this line in the same place:

_playerItem.AddObserver( this, "error", NSKeyValueObservingOptions.Initial | NSKeyValueObservingOptions.New, IntPtr.Zero );

These events can be seen in:

public override void ObserveValue( NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr context )

In your playerItem, look in _playerItem.ErrorLog to see your error.