Fckeditor 插入 MP3 或视频文件

之前有位朋友问我为什么Fckeditor不能插入MP3音乐的问题,当时真的不知道如何回答他。Fckeditor不久前刚刚发布了最新的版本2.5,功能又进一步强化了,我也把博客编辑器给更新了一下。

Google了一下,还是找到了解决插入MP3和视频文件的办法:http://blog.csdn.net/xinma/archive/2007/09/15/1785948.aspx

要说明一下,第一步中的D.src.endsWith(‘.swf’,true) 在以前的版本可能为C.src.endsWith(‘.swf’,true)。

修改前注意备份文件,以免造成不必要的麻烦。

一、分别打开:editor/js/fckeditorcode_ie_1.js和/editor/js/fckeditorcode_gecko_1.js

找到程序代码

以下是代码片段:
D.src.endsWith(‘.swf’,true)

替换为:

以下是代码片段:
D.src.endsWith(‘.swf’,true) || D.src.endsWith(‘.mpg’,true) || D.src.endsWith(‘.asf’,true) || D.src.endsWith(‘.wma’,true) || D.src.endsWith(‘.wmv’,true) || D.src.endsWith(‘.avi’,true) || D.src.endsWith(‘.mov’,true) || D.src.endsWith(‘.mp3’,true) || D.src.endsWith(‘.rm’,true) || D.src.endsWith(‘.ra’,true) || D.src.endsWith(‘.rmvb’,true) || D.src.endsWith(‘.mid’,true) || D.src.endsWith(‘.ram’,true)

文件格式你根据实际情况增加,基本上面的几种已经可以满足需要了。二、打开/editor/dialog/fck_flash/fck_flash.js1、增加程序代码

以下是代码片段:
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、替换程序代码

以下是代码片段:
e.type = ‘application/x-shockwave-flash’ ;
以下是代码片段:
if(WinPlayer(GetE(‘txtUrl’).value)!=null){
e.type = ‘application/x-mplayer2’ ;
}
if(RealPlayer(GetE(‘txtUrl’).value)!=null){
e.type = ‘audio/x-pn-realaudio-plugin’ ;
}
if(QuickTime(GetE(‘txtUrl’).value)!=null){
e.type = ‘video/quicktime’ ;
}
if(FlashPlayer(GetE(‘txtUrl’).value)!=null){
e.type = ‘application/x-shockwave-flash’ ;
e.pluginspage = ‘http://www.macromedia.com/go/getflashplayer’ ;
}

3、替换程序代码

以下是代码片段:
SetAttribute( e, ‘type’, ‘application/x-shockwave-flash’ ) ;
SetAttribute( e, ‘pluginspage’    , ‘http://www.macromedia.com/go/getflashplayer’ ) ;

以下是代码片段:
if(WinPlayer(GetE(‘txtUrl’).value)!=null){
e.type = ‘application/x-mplayer2’ ;
SetAttribute( e, ‘autostart’, GetE(‘chkAutoPlay’).checked ? ‘true’ : ‘false’ ) ;
}
if(RealPlayer(GetE(‘txtUrl’).value)!=null){
e.type = ‘audio/x-pn-realaudio-plugin’ ;
SetAttribute( e, ‘autostart’, GetE(‘chkAutoPlay’).checked ? ‘true’ : ‘false’ ) ;
}
if(QuickTime(GetE(‘txtUrl’).value)!=null){
e.type = ‘video/quicktime’ ;
SetAttribute( e, ‘autostart’, GetE(‘chkAutoPlay’).checked ? ‘true’ : ‘false’ ) ;
}
if(FlashPlayer(GetE(‘txtUrl’).value)!=null){
e.type = ‘application/x-shockwave-flash’ ;
SetAttribute( e, ‘scale’, GetE(‘cmbScale’).value ) ;
&nb
sp;  SetAttribute( e, ‘menu’, GetE(‘chkMenu’).checked ? ‘true’ : ‘false’ );
SetAttribute( e, ‘play’, GetE(‘chkAutoPlay’).checked ? ‘true’ : ‘false’ ) ;
}

6 thoughts to “Fckeditor 插入 MP3 或视频文件”

  1. 请问
    e.type = ‘application/x-shockwave-flash’ ;
    这一句在什么地方,我怎么没有找到?

  2. 用插入FLASH的按钮就可以插入MP3文件了,原来的FLASH仍然是可以用的

  3. 请问一下,按照您说的改完代码后,在FCKeditor编辑器哪个地方插入mp3呢?很谢谢

回复 feye 取消回复

您的电子邮箱地址不会被公开。 必填项已用*标注