简单生活

Simple life , it's as easy as 1,2,3...

利用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.js

1、增加程序代码
 
以下是代码片段:
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 ) ;
    SetAttribute( e, 'menu', GetE('chkMenu').checked ? 'true' : 'false' );
    SetAttribute( e, 'play', GetE('chkAutoPlay').checked ? 'true' : 'false' ) ;
« 用Google Earth鸟瞰我的世界是谁让尼采哭泣? »
    Gravatar头像
  • quote 2.请教
  • 2008-1-23 12:01:47 回复
  • 请问一下,按照您说的改完代码后,在FCKeditor编辑器哪个地方插入mp3呢?很谢谢
    狼的旋律 于 2008-1-23 16:11:43 回复
    用插入FLASH的按钮就可以插入MP3文件了,原来的FLASH仍然是可以用的
    Gravatar头像
  • quote 3.TT
  • 2008-2-16 16:00:46 回复
  • 不错,很实用~~
    Gravatar头像
  • quote 4.feye
  • 2008-2-18 15:11:19 回复

  • 请问
    e.type = 'application/x-shockwave-flash' ;
    这一句在什么地方,我怎么没有找到?
    狼的旋律 于 2008-2-18 15:54:39 回复
    可能是版本的问题,前面的参数e可能为其他的

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

关注我

最新评论及回复

赞助商链接

Powered By Z-Blog 1.8 Walle Build 91204
Copyright © 2007-2011 Wilf.cn. Some Rights Reserved