Videogular - toggleFullscreen()

Videogular - toggleFullscreen()

我尝试使用视频 API 切换到全屏,但我不明白。

奇怪的是,that.API.play() 运行良好,但 that.API.toggleFullscreen() 却不行。我检查了 vg-controls plugin-fullscreen-button,还有另一种方法叫做 onClickFullscreen() 但在我的例子中它也不起作用。

有人知道我该如何解决吗?我将它与 Ionic-App 一起使用,所以它可能有点复杂,但这里有一些来自控制器的代码:

    var that = this;
    that.onPlayerReady = function(API) {
        that.API = API;
    };

            if (window.matchMedia("(orientation: landscape)").matches) {
            // you're in LANDSCAPE mode
            console.log("Landscape") //works fine
            that.API.play(); //works also very fine
            that.API.toggleFullScreen(); //no chance....
        }

我在控制台也没有错误。所以看起来函数被调用了,但什么也没有发生。当我在控制台中写入 that.onClickFullScreen() 时,出现错误 "no function available for that object"。

Videogular 全屏仅适用于HTML5全屏API,您需要使用原生全屏API。对于这样的事情,我建议你使用 Cordova 插件。

有几个选项,这可能是一个:https://github.com/mesmotronic/cordova-plugin-fullscreen

另一种选择是在 Videogular 中禁用 HTML5 全屏。如果您禁用它,Videogular 将尝试占据整个 HTML 文档,这对您来说也是一个很好的解决方案。

<videogular vg-native-fullscreen="false">
    <!-- more stuff here -->
</videogular>