简单生活
返回文章列表
459 字3 分钟

Fckeditor 插入 MP3 或视频文件

软硬兼施#FCKeditor

之前有位朋友问我为什么 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)。

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

一、分别打开/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";
}

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";
}
if (RealPlayer(GetE("txtUrl").value) != null) {
e.type = "audio/x-pn-realaudio-plugin";
}

历史留言归档

8
静态只读归档
幼
幼峰
忒有用的东西了
请
请教
请问一下,按照您说的改完代码后,在FCKeditor编辑器哪个地方插入mp3呢?很谢谢
博
狼的旋律博主
用插入FLASH的按钮就可以插入MP3文件了,原来的FLASH仍然是可以用的
T
TT
不错,很实用~~
F
feye
<br/>请问<br/>e.type = 'application/x-shockwave-flash' ;<br/>这一句在什么地方,我怎么没有找到?
博
狼的旋律博主
可能是版本的问题,前面的参数e可能为其他的
手
手机用户3090219327
请问D.src.endsWith('.swf',true) 在哪呀,死活找不到啊,求截图
博
狼的旋律博主
放弃这个编辑器吧,新版的CKeditor,还有其他都很好