我正在使用JWPlayer来提供带有闪回后备功能的html5视频。
如果既没有html5也没有flash支持,我也希望有一个图像后备,但我看不到怎么做。
我的代码如下:
modes: [
{ type: "html5", },
{ type: "flash", src="http://www.mysite.com/jwplayer/player.swf"}
],
levels: [
{ file: "myvideo.mp4" }, // H.264 version
{ file: "myvideo.webm" }, // WebM version
{ file: "myvideo.ogg" } // Ogg Theroa version
],
有什么想法吗?感谢
答案 0 :(得分:2)
您可以使用两个utils函数来检查HTML5和Flash。您可以在source(复制并粘贴网址:http://developer.longtailvideo.com/trac/browser/trunk/js/src/utils/jwplayer.utils.js?rev=1311)中找到它们:
/**
* Detects whether the browser can handle HTML5 video.
* Using this as a proxy for detecting all HTML5 features needed for the JW HTML5 Player. Do we need more granularity?
*/
jwplayer.utils.hasHTML5 = function() {
return !!document.createElement('video').canPlayType;
};
/**
* Detects whether or not the current player has flash capabilities
* TODO: Add minimum flash version constraint: 9.0.115
*/
jwplayer.utils.hasFlash = function() {
return (typeof navigator.plugins != "undefined" && typeof navigator.plugins['Shockwave Flash'] != "undefined") || (typeof window.ActiveXObject != "undefined");
};