I have an AVPlayerItem
that I have been able to grab from my UIWebView (visiting a website with an AVPlayer/video-file in the HTML) using some AVPlayer callbacks in my ViewController.
I need to access the AVPlayer that has that item set as its AVPlayerItem.
As of now I am doing this by calling [TheAVPlayerItem valueForKey:@"player"];
but this is undocumented and not guaranteed to work in the future.
I'm looking for a more authoritative way of achieving this. I'd even be happy with literally starting at the UIWebView and looping down through all subviews (or sub-objects?) and grabbing any AVPlayer then checking if it has its AVPlayerItem set to my AVPlayerItem.... alas I don't know how to do that. But I have included my attempt at doing so:
//[TheAVPlayerItem valueForKey:@"player"];//undocumented and prone to breaking.
for (NSObject *anObject in [myWebView subviews]) {
if ([anObject isKindOfClass:[AVPlayer class]]) {
NSLog(@"Found an AVPlayer, now check if AVPlayerItem is a match");//never called
} else {
}
}
Of course the NSLog was never called.