图片视频预览直接将请求下载的url(返回为流)操作和显示

//看大图
function ShowBidPic(src, flag) {
    var bigImg = "";
    if (flag == "1") {//视频
        bigImg = "<video src='..\\..\\" + src + "' autoplay='autoplay' controls='controls' height='448' width='100%' />";
    }
    else if (flag == "2") {//图片
        bigImg = "<div><img src='..\\..\\" + src + "' height='100%' width='100%'/></div>";
    }
    else if (flag == "3") {//网址
        bigImg = "<iframe width='800' height='450' id='YuFrame1' name='YuFrame1' src='" + src + "' style='position:absolute;background-color:antiquewhite;z-index:4;' frameborder='0' marginheight='0' marginwidth='0' allowTransparency='true'></iframe>";
    }
    else if (flag == "4") {//flash
        bigImg = "<embed height='448' allownetworking='internal' allowscriptaccess='never' width='100%' quality='high' invokeurls='false' src='..\\..\\" + src + "' type='application/x-shockwave-flash' wmode='transparent'>";
    }


    layer.open({
        title: 'Media Details',
        // btn: ['关闭'],
        area: ['800px', '530px'],
        type: 1,
        closeBtn: 1, //不显示关闭按钮
        shift: 2,
        shadeClose: true, //开启遮罩关闭
        content: bigImg
    });
}

  完整的demo如下:

利用参数下载图片或者视频的ajax

var config = {
url: urlFile,
type: "get",
dataType: "json",
data: "",
success: function(result) {

}

};
$.ajax(config);

再返回的函数中进行判断操作例如:

                    url =ctx +'system/sysAttachment/downLoadFile?fileid='+id;
                                var bigImg =  "<video src=" + url + "  autoplay='autoplay' controls='controls' height='57%' width='60%' />";
                                window.parent.layer.open({
                                    title: ['视频在线播放','color:#fff;background-color:#01AAED;'],
                                    btn: ['关闭'],
                                    area: ['60%', '93%'],
                                    type: 1,
                                    closeBtn: 1, //不显示关闭按钮
                                    shift: 2,
                                    shadeClose: true, //开启遮罩关闭
                                    content: bigImg
                                });

 

posted @ 2020-08-20 17:33  逝年的我们  阅读(562)  评论(0编辑  收藏  举报