javascript - VideoJS - 按下播放按钮后禁用自动全屏
问题描述
由于 JWPlayer 荒谬的定价政策,我改用了 VideoJS。
问题是,当用户在 iOS 上启动视频时,它会切换原生全屏。我希望控制面板在全屏模式下可用,但我还无法管理它。
代码:
<video id="tvideo" class="video-js vjs-default-skin vjs-big-play-centered" controls preload="auto" poster="..." data-setup='{"language":"en", "controls": true,"autoplay": false, "fluid": true, "aspectRatio": "16:9", "playbackRates": [0.5, 1, 1.5, 2]}'>
<source src="..." type='video/mp4' label='240p' res='240'/>
<source src="..." type='video/mp4' label='360p' res='360'/>
<source src="..." type='video/mp4' label='720p' res='720'/>
<p class="vjs-no-js">Bu videoyu görüntülemek için lütfen JavaScript'i etkinleştirin.</p>
</video>
<script type="text/javascript">
var myPlayer = videojs("#tvideo");
myPlayer.videoJsResolutionSwitcher({
default: 'high',
dynamicLabel: true
});
myPlayer.persistvolume({
namespace: 'httpswwwseyredelimcom'
});
myPlayer.brand({
image: "...",
title: "...",
destination: "...",
destinationTarget: "_top"
});
myPlayer.ready(function() {
this.hotkeys({
volumeStep: 0.1,
seekStep: 5,
enableModifiersForNumbers: false
});
$(".bAd").detach().appendTo(".video-js");
$(".plAd").detach().appendTo(".video-js");
function resizeVideoJS() {
var containerWidth = $('.video-player').width();
var videoHeight = Math.round((containerWidth / 16) * 9);
myPlayer.width(containerWidth).height(videoHeight);
}
window.onresize = resizeVideoJS;
myPlayer.on("ended", function() {
startNextVideo();
});
});
</script>
我怎么能管理没有自动全屏并让用户在全屏上拥有控制面板?
提前致谢。
解决方案
实际上,这不会像 video.js 描述的那样工作。它适用于直接的 html5 播放器。
对于 video.js,您需要在设置对象的其他属性时使用 .playsinline(true)。您可以在 .ready() 上调用它。
这种方法对我有用:
instanceName.ready(function(){
myPlayer = this;
myPlayer.playsinline(true);
});
推荐阅读
- r - 如何使用 gls 将 SAS 中的 PROC MIXED 翻译成 R?(MMRM,AR1)
- reactjs - Redux 和 Sagas:无法正确连接
- pdf-generation - 我想在 JavaScript/Angular 9 中将 Word doc 的 base64 字符串转换为 PDF 的 base64 字符串
- c# - 在 Visual Studio 调试开始之前自动运行命令
- mule4 - Mule 4中的加密和解密
- python - Python Feedparser 发布到一个时区
- pyspark - 从终端向 Amazon EMR 集群提交 pyspark 作业
- ruby-on-rails - Rails 控制器处理差异开发/生产
- quarkus - 多文档事务的 MongoDB Panache 最佳实践
- similarity - 欧几里得距离系数