InAppBrowser无法在离子模式下以全屏模式播放Youtu

InAppBrowser无法在离子模式下以全屏模式播放Youtu

本文介绍了InAppBrowser无法在离子模式下以全屏模式播放Youtube视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Cordova和Ionic框架开发一个Android应用程序.我正在使用以下代码通过InAppBrowser播放YouTube视频:

window.open('https://www.youtube.com/watch?v=v8WjMiodcKo');

但是问题在于它会在浏览器中打开,但没有全屏模式选项来观看视频.反正有这样做吗?

解决方案

我知道答案有点老",但是当我遇到这个问题时,答案并不能真正解决潜在的问题:

对此的真正答案是,这是Cordova插件的局限性,因为它只是"使用"WebView".这基本上意味着,这个问题"可以归结为这个问题如答案所示,固定"代码在 GitHub 上维护.

要回到科尔多瓦,您可以做的是克隆inappbrowser-plugin 并以使用VideoEnabledWebView的方式进行更改,例如与此补丁.或者,您可以克隆我的叉子.我建议将它作为git-subtree添加到您的存储库中的某处

现在运行cordova plugin remove cordova-plugin-inappbrowser && cordova plugin add ./src/plugins/cordova-plugin-inappbrowser/(或您使用的任何路径).有了子树,您可以轻松地将更改贡献回原始插件(可悲的是,如果您阅读此信息,请这样做!),或从原始插件中提取更改/修复.

免责声明:我的用例是与Cordova一起玩耍",因此,如果您有其他要求,我建议您仔细测试此设置并回馈给原始插件以获取反馈./p>

I am developing an Android app using Cordova and Ionic framework. I am playing a YouTube video with InAppBrowser using the code below:

window.open('https://www.youtube.com/watch?v=v8WjMiodcKo');

But the issue is it opens inappbrowser but doesn't have full screen mode option to watch videos. Is there anyway to do this?

解决方案

I know that the answer is kind of "old" but as I run into this and the answer doesn't really fix the underlying problem:

The real answer to this is that this is a limitation of the Cordova plugin as it 'just' uses 'WebView'. This basically means this "issue" boils down to this question as indicated in the answer the "fixed" code is maintained on GitHub.

To get back to Cordova, what you can do is clone the inappbrowser-plugin and change it in a way to use the VideoEnabledWebView, for example with this patch. Alternatively you can clone my fork. I'd recommend to add this as git-subtree somewhere to your repository

Now run cordova plugin remove cordova-plugin-inappbrowser && cordova plugin add ./src/plugins/cordova-plugin-inappbrowser/ (or whatever path you used). With subtree you can easily contribute changes back to the original plugin (which I sadly did not do yet, if you read this please do!) or pull changes/fixes from the original plugin.

Disclaimer: My use-case was "playing around" with Cordova, so if you have other requirements I'd recommend testing this setup carefully and contributing back to the original plugin to get feedback.

这篇关于InAppBrowser无法在离子模式下以全屏模式播放Youtube视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-03 20:19