gpt4 book ai didi

javascript - Video.js 在 Safari 中不起作用(代码 :4 MEDIA_ERR_SRC_NOT_SUPPORTED)

转载 作者:行者123 更新时间:2023-12-01 15:18:30 31 4
gpt4 key购买 nike

我正在尝试使用 video.js 来防止快进,但允许倒带,用于 Moodle 网站上的 mp4 视频。它在 Chrome 和 Opera 中正常工作,但是当我在 Safari 中尝试时,我收到以下错误消息:

VIDEOJS: (4)
"ERROR:"
"(CODE:4 MEDIA_ERR_SRC_NOT_SUPPORTED)"
"The media could not be loaded, either because the server or network failed or because the format is not supported."

我看过一个 suggestion将 Content-Type header 更改为 mp4,但由于某种原因,我的 iframe不生成 head完全标记(仅在 Safari 中;在所有其他浏览器中, iframe 包含 html 标记,带有 headbody )。此外,事实证明,我无法在前面添加 head标记到 iframe html .我试着把它扔进 meta而是标记,但这对错误消息没有影响

以下是我用来防止快进的脚本:
<script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
<link href="https://vjs.zencdn.net/5.0/video-js.min.css" rel="stylesheet">
<script src="https://vjs.zencdn.net/5.0/video.min.js"></script>

<script>
window.onload = function() {
if ($('iframe').length > 0) {

$('iframe').ready(function() {
if ($('iframe').contents().find('head').length === 0) {
console.log("*********************");
console.log("In the if!");
$('iframe').contents().find('html').prepend("<head><meta name='viewport' content='width=device-width' content-type='video/mp4'></head>");
$('iframe').contents().find('html').attr("content-type", "video/mp4");
console.log($('iframe').contents().find('head'));
console.log($('iframe').contents().find('html'));
}

var videoPlayer = $('iframe').contents().find('video')[0];

var cssLink = document.createElement("link")
cssLink.href = "https://vjs.zencdn.net/5.0/video-js.min.css";
cssLink.rel = "stylesheet";
cssLink.type = "text/css";

$('iframe').contents().find('head').append(cssLink);

videojs(videoPlayer, {}, function() {
var vjsPlayer = this;
$('iframe').contents().find('video').prop('controls', 'true');
$('iframe').contents().find('div .vjs-big-play-button').html('');
$('iframe').contents().find('div .vjs-control-bar').html('');
$('iframe').contents().find('div .vjs-caption-settings').html('');

var currentTime = 0;

vjsPlayer.on("seeking", function(event) {
if (currentTime < vjsPlayer.currentTime()) {
vjsPlayer.currentTime(currentTime);
}
});

vjsPlayer.on("seeked", function(event) {
if (currentTime < vjsPlayer.currentTime()) {
vjsPlayer.currentTime(currentTime);
}
});

setInterval(function() {
if (!vjsPlayer.paused()) {
currentTime = vjsPlayer.currentTime();
}
}, 1000);
});
});
}
}

</script>

我的网络服务器是 Apache2。

任何有关如何启用 Content-Type video/mp4(或解决此错误的其他方法)的建议将不胜感激。

我也遇到了 Firefox 中视频的播放/暂停功能的问题和 Microsoft Edge .如果您有任何想法,请查看这些问题。

最佳答案

我在我的应用程序中遇到了同样的错误。经过几天的研究,我发现
safari 只能运行 H264 视频的编解码器格式。和 MP3、AAC 为音频。
检查视频格式和服务器响应。
供引用:https://docs.videojs.com/tutorial-troubleshooting.html#problems-when-hosting-media

关于javascript - Video.js 在 Safari 中不起作用(代码 :4 MEDIA_ERR_SRC_NOT_SUPPORTED),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34911845/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com