在我的应用程序中,用户可以从UIWebview打开YouTube,当全屏播放视频时,我收到通知,但我不能像mpmovieplayer控制器那样以编程方式控制暂停,播放,停止。
如何在webview中获得它?
当你想要停止音乐加载" url到web视图。所以它会停止。
这是代码:
[_Music_WbView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString: [NSString stringWithFormat:@""]]]];
_Music_WbView.hidden = YES;
if([_Music_WbView retainCount] > 0)
{
[_Music_WbView release];
_Music_WbView = nil;
}
In viewDidLoad
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(VideoExitFullScreen:) name:@"UIMoviePlayerControllerDidExitFullscreenNotification" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(VideoEnterFullScreen:) name:@"UIMoviePlayerControllerDidEnterFullscreenNotification" object:nil];
和for catch full screen
#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];