71

ios – 以编程方式强制UIWebView进入全屏模式

 5 years ago
source link: https://codeday.me/bug/20190112/504627.html?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
在UIWebview中播放媒体文件时(例如youtube)

html5媒体播放器有一个“全屏”按钮 – 我怎么能

>知道播放器何时进入全屏

>强制HTML5播放器进入全屏

要强制视频始终以全屏模式播放,在配置UIWebView时,请使用以下代码行:

webView.allowsInlineMediaPlayback = NO;

看起来有一些方法来 detect entering and leaving fullscreen ,虽然看起来这些不是推荐的方法.请参阅链接的StackOverflow问题.

根据你想要做的事情,你最好使用onStateChange回调检测玩家状态变化.在我正在进行的项目中,代码如下所示:

function onStateChange(event) {
        window.location.href = 'ytplayer://onStateChange?data=' + event.data;
    }

然后我在控制器或视图包装器类中嗅探此URL:

- (BOOL)webView:(UIWebView *)webView
shouldStartLoadWithRequest:(NSURLRequest *)request
            navigationType:(UIWebViewNavigationType)navigationType {
if([request.URL.scheme isEqualToString:@"ytplayer"]) {
    NSString *action = request.URL.host;

翻译自:https://stackoverflow.com/questions/21101695/programmatically-force-a-uiwebview-to-go-to-full-screen-mode


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK