在iOS中以编程方式为Webvideo播放控制YouTubevideo
在我的应用程序中,用户可以从UIWebview打开YouTube,我在全屏播放video时得到通知,但是我不能像mpmovieplayer控制器那样通过程序控制器来暂停,播放,停止。
我怎样才能得到它在webview?
每当你想停止音乐加载“”url到networking视图。 所以它会停止。
这是代码:
[_Music_WbView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString: [NSString stringWithFormat:@""]]]]; _Music_WbView.hidden = YES; if([_Music_WbView retainCount] > 0) { [_Music_WbView release]; _Music_WbView = nil; }
在viewDidLoad中
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(VideoExitFullScreen:) name:@"UIMoviePlayerControllerDidExitFullscreenNotification" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(VideoEnterFullScreen:) name:@"UIMoviePlayerControllerDidEnterFullscreenNotification" object:nil];
并捕捉全屏
#pragma mark - UIMoviePlayerController notification handle - (void)VideoExitFullScreen:(id)sender{ NSLog(@"Exit from Full Screen.."); } - (void)VideoEnterFullScreen:(id)sender { NSLog(@"Enter in Full Screen.."); [web goBack]; //back to notmal webview.. or pause the video }
NSURL *websiteUrl = [NSURL URLWithString:@"Link of Youtube Video"]; NSURLRequest *urlRequest = [NSURLRequest requestWithURL:websiteUrl]; [myWebView loadRequest:urlRequest];