以编程方式为 iOS 中的 YouTube 视频进行 Webview 播放控制 [英] Webview playback control programmatically for YouTube video in iOS
本文介绍了以编程方式为 iOS 中的 YouTube 视频进行 Webview 播放控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用程序中,用户可以从 UIWebview 打开 YouTube,我在全屏播放视频时收到通知,但我无法像 mpmovieplayer 控制器那样以编程方式控制暂停、播放、停止.
In My App, User can open YouTube from UIWebview, I got notification when plays video in full screen, but I can't get control programmatically like mpmovieplayer controller to pause, play, stop.
如何在 webview 中获取它?
How can I get it in webview?
推荐答案
In viewDidLoad
In 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
}
这篇关于以编程方式为 iOS 中的 YouTube 视频进行 Webview 播放控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文