无法使用JW播放器播放mp4 [英] Could not play mp4 with JW player
问题描述
我已经阅读了很多类似的主题,但是没有找到解决我问题的方法.
I've read a lot of similar topics but did not manage to find a solution to my problem.
我正在使用Apache tomcat和localhost:8080托管我的html.我从不同的来源下载了许多mp4文件,但这些文件都无法播放.错误提示:错误加载媒体:无法播放文件.但是,如果我将它们上传到我的YouTube频道并使用URL,它们就可以完美播放.
I'm using Apache tomcat and localhost:8080 to host my html. I've download a lot of mp4 files from different sources and none of then can be played. Error says: error loading media: file could not be played. But if i upload them into my youtube channel and use the URL, they can be played perfectly.
我不知道如何检查或添加MIME类型.而且我相信我所有的mp4文件都使用H.264/AAC编码.
I don't know how to check or add MIME type in my case. And i believe all my mp4 files use H.264/AAC encoding.
这是我的代码:
jwplayer("myElement").setup({
width: "480",
height:"320",
id:"playerID",
file: "/jwplayer/uploads/fails.mp4",
image: "/jwplayer/uploads/bbc-logo9.jpg",
tracks:[{
file:"/jwplayer/uploads/captions_en.vtt",
label:"English",
kind:"captions",
default:true
}]
});
推荐答案
由于使用的是Apache,因此应在试图播放mp4文件的文件夹中创建一个.htaccess文件.
Since you are using Apache, you should create a .htaccess file in the same folder that the mp4 files reside in that you are trying to play.
这是一个示例.htaccess文件,它将为您添加一些常见的MIME类型.
Here is a sample .htaccess file that will add some common MIME TYPEs for you.
<IfModule mod_rewrite.c>
AddType video/ogg .ogv
AddType video/webm .webm
AddType video/mp4 .mp4
</IfModule>
只要MP4文件是用H264/AAC编码的,这应该可以工作.
This should work, as long as the MP4 files are encoded in H264/AAC.
这篇关于无法使用JW播放器播放mp4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!