问题
I googled and I found jPlayer for playing video content over the net. But jPlayer does not play .flv (flash video) files. I mentioned path correctly for swf player. it is inside the js folder and js folder is at the same lever where my example.html code file is. my code is as below example.html
$("#jquery_jplayer_1").jPlayer({
ready: function () {
$(this).jPlayer("setMedia", {
m4v: "media/royalrumble.mp4",
flv: "media/royalrumble.flv",
poster: "media/royalrumble.jpg"
});
},
swfPath: "js",
supplied: "m4v, flv"
});
回答1:
The code below worked for me
$("#jquery_jplayer_1").jPlayer({
ready: function () {
$(this).jPlayer("setMedia", {
m4v: "../media/royalrumble.mp4",
flv: "../media/royalrumble.flv",
poster: "media/royalrumble.jpg"
});
},
swfPath: "js",
supplied: "m4v, flv",
});
I dont know why? the media directory is at same lever where my code exists. still it does not accept
m4v: "media/royalrumble.mp4",
flv: "media/royalrumble.flv",
and
m4v: "../media/royalrumble.mp4",
flv: "../media/royalrumble.flv",
worked fine.
it means that path provided should be relative to jPlayer.swf file.
回答2:
Hope its OK that i just add a little info, bc. i have the same problem in IE, but found a fix seaching the web.
Can see thats there is alot that have problemt with IE and the "Media URL could not be loaded" after seaching, i found out that if I use FLV fil for IE and did a ../ to the path, then it will work for IE.
So i started with this.
<script type="text/javascript">
//<![CDATA[
$(document).ready(function () {
$("#jquery_jplayer_1").jPlayer({
ready: function () {
$(this).jPlayer("setMedia", {
mp4: "video/Soccer.mp4",
webmv: "video/Soccer.webm",
flv: "video/Soccer.flv",
m4v: "video/Soccer.m4v",
ogv: "video/Soccer.ogv",
poster: "video/Soccer.png"
});
},
//error: function (event) {
// console.log(event.jPlayer.error);
// console.log(event.jPlayer.error.type);
//},
swfPath: "add/jplayer.swf",
errorAlerts: true,
supplied: "mp4, webmv, flv, m4v, ogv",
solution: "html,flash",
size: {
width: "640px",
height: "360px",
cssClass: "jp-video-360p"
},
smoothPlayBar: true,
keyEnabled: true
});
$("#jplayer_inspector").jPlayerInspector({ jPlayer: $("#jquery_jplayer_1") });
});
//]]>
</script>
And that was not working i IE, but in FF and Safari, iPhone/iPad. And ended up with this, thats works 100% in FF, Safari, IE and iPhone/iPad...
<script type="text/javascript">
//<![CDATA[
$(document).ready(function () {
$("#jquery_jplayer_1").jPlayer({
ready: function () {
$(this).jPlayer("setMedia", {
mp4: "video/Soccer.mp4",
webmv: "video/Soccer.webm", //WEBM. works for FF
flv: "../video/Soccer.flv", //FLV. works for IE, but u need ../ in front of the path...
m4v: "video/Soccer.m4v", //M4V. works for FF, Saf, iPhone/iPad
ogv: "video/Soccer.ogv",
poster: "video/Soccer.png"
});
},
//error: function (event) {
// console.log(event.jPlayer.error);
// console.log(event.jPlayer.error.type);
//},
swfPath: "add/jplayer.swf",
errorAlerts: true,
supplied: "mp4, webmv, flv, m4v, ogv",
solution: "html,flash",
size: {
width: "640px",
height: "360px",
cssClass: "jp-video-360p"
},
smoothPlayBar: true,
keyEnabled: true
});
$("#jplayer_inspector").jPlayerInspector({ jPlayer: $("#jquery_jplayer_1") });
});
//]]>
来源:https://stackoverflow.com/questions/10786034/how-play-flv-files-using-jplayer