frankchia

为kindeditor添加在线播放视频功能(基于原有flash上传,mp4,flv,flash)

kindeditor本身支持上传flash功能,但是我们经常需要上传一些flv、mp4或则其它格式的视频。

其实具体的播放功能是通过jwplayer实现的。我只对kindeditor简单的修改了一下。需要修改的文件有两处。

打开kindeditor\kindeditor.js文件

将以下函数语句修改

[javascript] view plain copy
 
  1. //修改过的功能 by zhjx922  
  2. function _mediaEmbed(attrs) {  
  3.     var html = \'<embed id="player" name="player" allowscriptaccess="always" allowfullscreen="true" \';  
  4.     _each(attrs, function(key, val) {  
  5.         html += key + \'="\' + val + \'" \';  
  6.     });  
  7.     html += \'/>\';  
  8.     return html;  
  9. }  

打开kindeditor\plugins\flash\flash.js文件

将一下内容:

[javascript] view plain copy
 
  1. var html = K.mediaImg(self.themesPath + \'common/blank.gif\', {  
  2.                                 src : url,  
  3.                                 type : K.mediaType(\'.swf\'),  
  4.                                 width : width,  
  5.                                 height : height,  
  6.                                 quality : \'high\'  
  7.                             });  


修改为:

[javascript] view plain copy
 
  1. var html = K.mediaImg(self.themesPath + \'common/blank.gif\', {  
  2.                                 flashvars : \'file=\' + url,  
  3.                                 src : \'plugins/jwplayer/player.swf\',  
  4.                                 type : K.mediaType(\'.swf\'),  
  5.                                 width : width,  
  6.                                 height : height,  
  7.                                 quality : \'high\'  
  8.                             });  


再将大约140行左右的:

urlBox.val(attrs.src);

修改为:

urlBox.val(attrs.flashvars);

 

然后在需要显示视频的页面放入以下代码:

head放入:<script type="text/javascript" src="plugins/jwplayer/jwplayer.js"></script>

在输入视频代码后加上:

[javascript] view plain copy
 
  1. <script type=\'text/javascript\'>  
  2. //非视频,不加载播放器  
  3. if(document.getElementById(\'player\')!=null)  
  4. {  
  5.  jwplayer(\'player\').onReady(function() {});  
  6.  jwplayer(\'player\').onPlay(function() {});  
  7.  //jwplayer(\'player\').play(); //自动播放?  
  8.  }  
  9. </script>  
  10.   
  11. OK。  




附件下载地址:http://download.csdn.net/detail/zhjx922/4329134

 

分类:

技术点:

相关文章: