Creación del complemento Phonegap / Cordova IOS para iniciar el video con AVPlayer

Si bien este ejemplo de un complemento Phonegap funciona bien para reproducir videos utilizando MPMoviePlayerController, estoy buscando un enfoque similar para iniciar videos con el AVPlayer en su lugar (aún en un complemento Phonegap).

Necesito algo como esto, pero no puedo imaginar cómo llamar al jugador y get la vista del jugador iniciada por el complemento.

AVPlayerViewPlay es la llamada de CDVPlugin:

// AVPlayerViewPlay.h // #import <Cordova/CDV.h> #import <UIKit/UIKit.h> #import "AVPlayerView.h" #import "AVPlayerViewController.h" @class AVPlayerViewController; @interface AVPlayerViewPlay : CDVPlugin - (void)play:(CDVInvokedUrlCommand*)command; @end // // AVPlayerViewPlay.m // #import <Cordova/CDV.h> #import <AVFoundation/AVFoundation.h> #import "AVPlayerViewPlay.h" #import "AVPlayerViewController.h" @implementation AVPlayerViewPlay - (void)play:(CDVInvokedUrlCommand*)command { CDVPluginResult* pluginResult = nil; NSString* javaScript = nil; //!! WHAT DO I NEED TO DO HERE TO START the AVPlayerView and play the 2 videos AS A PHONEGAP PLUGIN?? //self.playbackViewController = [[AVPlayerViewController alloc] init]; //[self.playbackViewController setURL:URLWithString:movie]; pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"PLUGIN WORKS "]; javaScript = [pluginResult toSuccessCallbackString:command.callbackId]; [self writeJavascript:javaScript]; } - (void)dealloc { [super dealloc]; } @end 

AVPlayerView es la vista de AVPlayer:

 // // AVPlayerView.h // #import <UIKit/UIKit.h> @class AVPlayer; @interface AVPlayerView : UIView @property (nonatomic, retain) AVPlayer* player; - (void)setPlayer:(AVPlayer*)player; - (void)setVideoFillMode:(NSString *)fillMode; @end // // AVPlayerView.m // #import "AVPlayerView.h" #import <AVFoundation/AVFoundation.h> @implementation AVPlayerView + (Class)layerClass { return [AVPlayerLayer class]; } - (AVPlayer*)player { return [(AVPlayerLayer*)[self layer] player]; } - (void)setPlayer:(AVPlayer*)player { [(AVPlayerLayer*)[self layer] setPlayer:player]; } - (void)setVideoFillMode:(NSString *)fillMode { AVPlayerLayer *playerLayer = (AVPlayerLayer*)[self layer]; playerLayer.videoGravity = fillMode; } @end 

AVPlayerViewController es el controller AVPlayer:

 // // AVPlayerViewController.h // #import <UIKit/UIKit.h> #import <AVFoundation/AVFoundation.h> @class AVPlayerViewController; @interface AVPlayerViewController : UIViewController { AVQueuePlayer *queuePlayer; IBOutlet AVPlayerViewController *mPlaybackView; } @property (readwrite, retain) AVQueuePlayer *queuePlayer; @property (nonatomic, retain) IBOutlet AVPlayerViewController *mPlaybackView; - (void)observeValueForKeyPath:(NSString*) path ofObject:(id)object change:(NSDictionary*)change context:(void*)context; @end // // AVPlayerViewController.m // #import "AVPlayerViewController.h" #import "AVPlayerView.h" static void *AVPlayerDemoPlaybackViewControllerStatusObservationContext = &AVPlayerDemoPlaybackViewControllerStatusObservationContext; @implementation AVPlayerViewController @synthesize mPlaybackView, queuePlayer; - (void)dealloc { [queuePlayer release]; [mPlaybackView release]; [super dealloc]; } - (void)viewDidLoad { [super viewDidLoad]; NSString *secondVideoPath = [[NSBundle mainBundle] pathForResource:@"video1" ofType:@"mp4"]; NSString *firstVideoPath = [[NSBundle mainBundle] pathForResource:@"video2" ofType:@"mov"]; AVPlayerItem *firstVideoItem = [AVPlayerItem playerItemWithURL:[NSURL fileURLWithPath:firstVideoPath]]; AVPlayerItem *secondVideoItem = [AVPlayerItem playerItemWithURL:[NSURL fileURLWithPath:secondVideoPath]]; self.queuePlayer = [AVQueuePlayer queuePlayerWithItems:[NSArray arrayWithObjects:firstVideoItem, secondVideoItem,nil]]; // I get a WARNING here that AVPlayerViewController may not respong to 'setPlayer' [self.mPlaybackView setPlayer:self.queuePlayer]; [self.queuePlayer play]; } @end 

He buscado en todas partes y no puedo encontrar ningún ejemplo de complemento. El código anterior fue inspirado básicamente desde aquí (IOS Native). Trabajo principalmente con Javascript, así que creo que mi problema es averiguar cómo replace los botones IBoutlet Play de Interface Builder mediante una llamada de complemento de Phonegap.

¡Gracias!