根据http和https显示视频

This commit is contained in:
yuanke 2016-06-06 09:34:45 +08:00
parent c3c639aa77
commit 4c92e73cf1
1 changed files with 38 additions and 1 deletions

View File

@ -1347,6 +1347,43 @@ function pop_up_box(value,tWidth,tTop,tLeft){
}
}
//显示的时候根据当前网址是http 还是https 选择视频显示方式直接显示还是弹框
function autoMedia(id){
var rootPath = getRootPath();
function _mediaType(src) {
if (/\.(rm|rmvb)(\?|$)/i.test(src)) {
return 'audio/x-pn-realaudio-plugin';
}
if (/\.(swf|flv)(\?|$)/i.test(src)) {
return 'application/x-shockwave-flash';
}
return 'video/x-ms-asf-plugin';
}
if (rootPath.indexOf("https") < 0){
$("#"+id+" img").each(function(){
if ($(this).attr("class") == "mediaIco"){
var href = $(this).parent().attr("href");
//正则取地址
if (href){
var url = href.split("open('")[1].split("',")[0];
if (url != ""){
var type = _mediaType(url);
//1.video/x-ms-asf-plugin 类型的视频播放不了,2.audio/x-pn-realaudio-plugin没试过3.application/x-shockwave-flash可以播放
if (type != "video/x-ms-asf-plugin"){
var width = 550;
var height = 400;
var html = '<embed src="'+url+'" allowFullScreen="true" quality="high" width="'+width+'" height="'+height+'" align="middle" allowScriptAccess="always" type="'+type+'"></embed>';
$(this).parent().replaceWith(html);
}
}
}
}
});
}
}
//yk 自动识别URL 并加上链接
function autoUrl(id){
if ($("#"+id).children().length > 0 ){
@ -1387,6 +1424,6 @@ function autoUrl(id){
});
$("#"+id).html(html);
}
autoMedia(id);
}