kindeditor本身支持上传flash功能,但是我们经常需要上传一些flv、mp4或则其它格式的视频。
其实具体的播放功能是通过jwplayer实现的。我只对kindeditor简单的修改了一下。需要修改的文件有两处。
打开kindeditorkindeditor.js文件
将以下函数语句修改
[javascript]
view plain
copy
print
?
- ??
- function?_mediaEmbed(attrs)?{??
- ????var?html?=?'<embed?id="player"?name="player"?allowscriptaccess="always"?allowfullscreen="true"?';??
- ????_each(attrs,?function(key,?val)?{??
- ????????html?+=?key?+?'="'?+?val?+?'"?';??
- ????});??
- ????html?+=?'/>';??
- ????return?html;??
- }??
打开kindeditorpluginsflashflash.js文件
将一下内容:
[javascript]
view plain
copy
print
?
- var?html?=?K.mediaImg(self.themesPath?+?'common/blank.gif',?{??
- ????????????????????????????????src?:?url,??
- ????????????????????????????????type?:?K.mediaType('.swf'),??
- ????????????????????????????????width?:?width,??
- ????????????????????????????????height?:?height,??
- ????????????????????????????????quality?:?'high'??
- ????????????????????????????});??
修改为:
[javascript]
view plain
copy
print
?
- var?html?=?K.mediaImg(self.themesPath?+?'common/blank.gif',?{??
- ????????????????????????????????flashvars?:?'file='?+?url,??
- ????????????????????????????????src?:?'plugins/jwplayer/player.swf',??
- ????????????????????????????????type?:?K.mediaType('.swf'),??
- ????????????????????????????????width?:?width,??
- ????????????????????????????????height?:?height,??
- ????????????????????????????????quality?:?'high'??
- ????????????????????????????});??
再将大约140行左右的:
urlBox.val(attrs.src);
修改为:
urlBox.val(attrs.flashvars);
然后在需要显示视频的页面放入以下代码:
head放入:<script type="text/javascript" src="plugins/jwplayer/jwplayer.js"></script>
在输入视频代码后加上:
[javascript]
view plain
copy
print
?
- <script?type='text/javascript'>??
- ??
- if(document.getElementById('player')!=null)??
- {??
- ?jwplayer('player').onReady(function()?{});??
- ?jwplayer('player').onPlay(function()?{});??
- ???
- ?}??
- </script>??
- ??
- OK。??
附件下载地址:http://download.csdn.net/detail/zhjx922/4329134