问题
I've read a lot of similar topics but did not manage to find a solution to my problem.
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.
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.
Here is my code:
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
}]
});
回答1:
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.
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>
This should work, as long as the MP4 files are encoded in H264/AAC.
回答2:
OK, i think i found the problem.
I tried to open my site in IE 9 and this time it works fine, the demo video on http://www.longtailvideo.com/jw-player/ also works fine now.
Seems that there's some problem with my chrome. I think i'll just use IE instead and focus on my project.
Thanks Ethan.
And of course if someone knows what's wrong with my chrome and how to fix it, please, you are more than welcomed to post your solution.
来源:https://stackoverflow.com/questions/16935050/could-not-play-mp4-with-jw-player