在FCKeditor 2.6中添加插入视频和音频功能(最新修订版)
修改前注意備份文件,以免造成不必要的麻煩。
一、分別打開:editor/js/fckeditorcode_ie.js和/editor/js/fckeditorcode_gecko.js
找到程序代碼
以下是代碼片段:
Js代碼
||/\.swf($|#|\?)/i.test(A.src)
這段代碼的主要用來判斷后綴名,如果后綴名不是swf則返回,把它替換為:
?以下是代碼片段:
Js代碼
||/\.swf($|#|\?)/i.test(A.src)||/\.mpg($|#|\?)/i.test(A.src)||/\.asf($|#|\?)/i.test(A.src)||/\.wma($|#|\?)/i.test(A.src)||/\.wmv($|#|\?)/i.test(A.src)||/\.avi($|#|\?)/i.test(A.src)||/\.mov($|#|\?)/i.test(A.src)||/\.mp3($|#|\?)/i.test(A.src)||/\.rmvb($|#|\?)/i.test(A.src)||/\.mid($|#|\?)/i.test(A.src)
文件格式可以根據情況來修改,但是注意要和其他的幾個地方吻合
二、打開/editor/dialog/fck_flash/fck_flash.js
1、增加程序代碼,這段代碼用來判斷后綴名
Js代碼
function WinPlayer(url){??
var r, re;??
re = /.(avi|wmv|asf|wma|mid|mp3|mpg)$/i;??
r = url.match(re);??
return r;??
}??
???
function RealPlayer(url){??
var r, re;??
re = /.(.rm|.ra|.rmvb|ram)$/i;??
r = url.match(re);??
return r;??
}??
???
function QuickTime(url){??
var r, re;??
re = /.(mov|qt)$/i;??
r = url.match(re);??
return r;??
}??
???
function FlashPlayer(url){??
var r, re;??
re = /.swf$/i;??
r = url.match(re);??
return r;??
}?
2、替換程序代碼,這段代碼是在UpdatePreview中用來添加type屬性
SetAttribute(?e,?'type',?'application/x-shockwave-flash'?)?;?
為
if(WinPlayer(GetE('txtUrl').value)!=null){??
SetAttribute( e, 'type', 'application/x-mplayer2' ) ;??
}??
if(RealPlayer(GetE('txtUrl').value)!=null){??
SetAttribute( e, 'type', 'audio/x-pn-realaudio-plugin' ) ;??
}??
if(QuickTime(GetE('txtUrl').value)!=null){??
SetAttribute( e, 'type', 'application/video/quicktime' ) ;??
}??
if(FlashPlayer(GetE('txtUrl').value)!=null){??
SetAttribute( e, 'type', 'application/x-shockwave-flash' ) ;??
SetAttribute( e, 'pluginspage', 'http://www.macromedia.com/go/getflashplayer ' ) ;??
}?
3、替換程序代碼,這段代碼是在UpdateEmbed中用來添加type屬性
?SetAttribute( e, 'type' , 'application/x-shockwave-flash' ) ;??
SetAttribute( e, 'pluginspage' , 'http://www.macromedia.com/go/getflashplayer ' ) ;?
為
if(WinPlayer(GetE('txtUrl').value)!=null){??
??? SetAttribute( e, 'type' , 'application/x-mplayer2' ) ;??
??? SetAttribute( e, 'autostart', GetE('chkAutoPlay').checked ? 'true' : 'false' ) ;??
}??
if(RealPlayer(GetE('txtUrl').value)!=null){??
??? SetAttribute( e, 'type' , 'audio/x-pn-realaudio-plugin' ) ;??
??? SetAttribute( e, 'autostart', GetE('chkAutoPlay').checked ? 'true' : 'false' ) ;??
}??
if(QuickTime(GetE('txtUrl').value)!=null){??
??? SetAttribute( e, 'type' , 'video/quicktime' ) ;??
??? SetAttribute( e, 'autostart', GetE('chkAutoPlay').checked ? 'true' : 'false' ) ;??
}??
if(FlashPlayer(GetE('txtUrl').value)!=null){??
??? SetAttribute( e, 'type' , 'application/x-shockwave-flash' ) ;??
??? SetAttribute( e, 'pluginspage' , 'http://www.macromedia.com/go/getflashplayer ' ) ;??
}?
?
三、打開/fckconfig.js,該文件為配置文件
替換程序代碼,這個是在上傳文件的時候檢查后綴名
?
FCKConfig.FlashUploadAllowedExtensions?=?".(swf)$"?;?//?empty?for?all??
為
?FCKConfig.FlashUploadAllowedExtensions???
??? = ".(swf|fla|mpg|asf|wma|wmv|avi|mov|mp3|rmvb|mid)$" ; // empty for all?
?
三、打開/editor/lang/zh-cn.js 文件,該部分為語言文件,Flash替換掉就可以了
然后整體修改完成,現(xiàn)在已經支持上傳視頻和音頻文件,不過注意的是,如果視頻文件太大,還是可能出現(xiàn)不能播放的情況
四、總結(重要的部分哦)
費話:很少寫技術文檔,是心愛的人改變了我,HOHO,不得不承認愛的力量很偉大。
正題:到第三步的時候,自己測試,上傳一個wmv格式的視頻,結果提示不支持的格式,仔細查找了一下,問題出在ascx文件。費話少說,找到/editor/filemanager/connectors/aspx/config.ascx,打開這個文件,修改TypeConfig["Flash"].AllowedExtensions后面的數(shù)組,個人覺得支持最好的格式為:flv,wmv,wma,mp3,asf,最好是支持什么文件就添加什么文件,不然不支持你上傳到服務器,就會產生大量的垃圾文件,HOHO,到這里就大功告成了,經過測試OK,如果有什么技術疑問可以加QQ22550450,that's all,see you next Article.
:)
轉載于:https://www.cnblogs.com/Joseph_net/archive/2010/10/07/1844984.html
總結
以上是生活随笔為你收集整理的在FCKeditor 2.6中添加插入视频和音频功能(最新修订版)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: WCF面向服务应用程序系列之一:Hell
- 下一篇: 诺基亚力邀App开发员加入Ovi以对抗苹