KinderEditor视频上传播放修改

 

代码

 1 function _mediaImg(blankPath, attrs) {
 2 //原版
 3 // var width = attrs.width,
 4 //     height = attrs.height,
 5 //     type = attrs.type || _mediaType(attrs.src),
 6 //     srcTag = _mediaEmbed(attrs),
 7 //     style = '';
 8 //修改
 9     var width = attrs.width,
10         height = attrs.height,
11         type = attrs.type || _mediaType(attrs.src),
12         style = '';
13     var src = attrs.src;
14     if (src.indexOf(".flv") > 0) {
15         attrs.src = "http://www.cnblogs.com/../KindEditor/FLVPlayer_Progressive.swf?MM_ComponentVersion=1&skinName=http://www.cnblogs.com/../KindEditor/Clear_Skin_3&autoPlay=false&autoRewind=false&streamName=" + attrs.src + "";
16     }
17     var srcTag = _mediaEmbed(attrs)
18 
19     if (width > 0) {
20         style += 'width:' + width + 'px;';
21     }
22     if (height > 0) {
23         style += 'height:' + height + 'px;';
24     }
25     var html = '<img class=" + _mediaClass(type) + " src="' + blankPath + '" ';
26     if (style !== '') {
27         html += 'style="' + style + '" ';
28     }
29     html += 'data-ke-tag="' + escape(srcTag) + '" alt=""/>';
30     return html;
31 }

 

解决方法

第1步:打开引入kindertor.js。查找到function _mediaImg(blankPath, attrs) 该方法位置,覆盖原方法即可。

说明 直接用kindeditor 上传的flv文件无法播放。查HTML代码得视频代码为<embed src="/attached/flash/20130504/20130504124421_7674.flv" type="application/x-shockwave-flash" width="480" height="400" quality="high" />

这种模式可以直接播swf文件,但若要放FLV得用个播放器,结果的代码为,player.swf?video.flv&各种参数

代码只不过多加了个判断逻辑

如果是flv文件,则修改src为引号内的字符串

if (src.indexOf(".flv") > 0) {
    attrs.src = "http://www.cnblogs.com/../KindEditor/FLVPlayer_Progressive.swf?MM_ComponentVersion=1&skinName=http://www.cnblogs.com/../KindEditor/Clear_Skin_3&autoPlay=false&autoRewind=false&streamName=" + attrs.src + "";
}

知道在哪改,这段代码随便从哪扒一个。src.indexOf(".flv") > 0 这种验证不严谨,不满意的自已改

上面这是我从dreamwave里扒的,用dreamwave发个视频把代码拷下来。

 

直接改的话,注意路径。

posted @ 2013-05-04 13:55  cclient  阅读(653)  评论(0编辑  收藏  举报