【问题标题】:Jwplayer not working on safari and IOsJwplayer 不适用于 safari 和 IO
【发布时间】:2016-12-06 15:24:13
【问题描述】:

我今天在使用 JWPlayer 时遇到问题。

在 Chrome、FF 和 Edge 上一切正常,但在移动设备和 Safari 浏览器上却不行。我收到以下错误消息:

加载媒体时出错:无法播放文件 根据文档,我使用了错误的媒体格式,但它适用于移动设备和 Safari 浏览器上的所有浏览器。

这是我对 JWplayer 7.8.2 客户端的设置:

<div id="preview_video>
</div>
<script type="text/javascript">
    jwplayer("preview_video").setup({                                                                       
        playlist: [{
            sources: [{
                    file:"myfile.flv",
                    type: 'flv'
                },{
                    file:"myfile.mp4"
                    // fallback mp4 file in case flash is disabled or not allowed
                    type:'mp4'
                }],
            image:"myfile_image.jpg"
        }],
        primary : 'flash',
        aspectratio : "16:9",
        width: "100%"
    });
</script>

这是我的服务器端代码

if($_REQUEST["format"] == 'mp4'){
    $mediaPath = $myfile."mp4";
    $content_type = "video/mp4";
}else{
    $mediaPathPhoto = $myfile".flv";
    $content_type = "video/x-flv";
}
header("Content-Type: {$content_type}");
header("Content-Length: ".filesize($mediaPath));
readfile($mediaPath);
exit();

通过谷歌搜索了几个小时后,我来到这里希望有人可以帮助我..

谢谢你

【问题讨论】:

    标签: javascript ios safari jwplayer mp4


    【解决方案1】:

    JWPlayer 依靠 Adobe Flash Player 浏览器插件来解码和显示 FLV 文件。此插件在官方 Android 或 iOS 浏览器上不可用。

    解决方案

    仅通过 HTML5 使用 MP4 格式。两种格式(FLV 与 MP4)都可以包含完全相同的数据(带有 MP3 或 AAC 音频的 h.264 视频),但更多设备和软件支持 MP4。

    iOS 使用 HTML5 并且仅接受 MP4。

    设置 primary : 'html5' 并提供 MP4 链接。在不支持 HTML5 的情况下,由于 Flash Player 可以解码 MP4 或 FLV 格式,因此 MP4 文件仍然可以通过 Flash(后备)播放。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-11
      • 2019-01-26
      • 1970-01-01
      • 2018-06-09
      • 2014-03-04
      • 1970-01-01
      相关资源
      最近更新 更多