随笔 - 15, 文章 - 0, 评论 - 5, 引用 - 0
数据加载中……

FckEditor上传音频视频

FckEditor上传音频视频
         在Fckeditor中加入上传音频视频功能,办法是通过扩展原来的flash上传来实现。过程中出现了乱码问题,现在把调试的过程记录下来。部分内容参考了“玉树临风真情无限”的日志。

         软件版本:FckEditor2.6.2;平台:Windows XP;数据库:MySQL。
1.  分别打开editor/js文件夹下的fckeditorcode_ie.js、fckeditorcode_gecko.js文件。将代码:
||/\.swf($|#|\?)/i.test(A.src)
替换为:
||/\.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)
6        这段代码用来判断文件后缀名,当然文件格式可以自定义,不过要考虑和其他地方相吻合。
2. 打开/editor/dialog/fck_flash/fck_flash.js文件。
2.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.2 替换两个地方的代码:一个在UpdatePreview()中,将:
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' ) ;

}

另一个地方在UpdateEmbed()中,将: 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' ) ;

}

3.打开/fckconfig.js文件,将:
FCKConfig.FlashUploadAllowedExtensions = ".(swf)$" ; // empty for all
替换为:
FCKConfig.FlashUploadAllowedExtensions = ".(swf|fla|mpg|asf|wma|wmv|avi|mov|mp3|rmvb|mid)$" ; // empty for all
      到此,基本功能已经完成。剩下的是一些细节的设置。
4. 其他设置
4.1 编辑框中文字的设置:打开/editor/lang/zh-cn.js 文件,将flash替换成想要显示的文字。
4.2 默认的音频视频播放效果是循环、自动播放、带操作menu的样式,可以通过设置来显示成想要的效果。方法还是在/editor/dialog/fck_flash/fck_flash.js文件,在UpdateEmbed()方法中,将对应的文件格式中的,
SetAttribute( e, 'play', GetE('chkAutoPlay').checked ? 'true' : 'false' )替换为:

SetAttribute( e, 'autostart', GetE('chkAutoPlay').checked ? 'false' : 'true' ) ;
    

 

 

posted on 2008-07-27 11:21 zhouzhou@ 阅读(855) 评论(3)  编辑  收藏

评论

# re: FckEditor上传音频视频  回复  更多评论   

问一下:你尝试过么?为什么我再上传非swf文件的时候仍然说Invalid file?
2008-09-03 01:22 | Stars

# re: FckEditor上传音频视频  回复  更多评论   

尝试过
2008-09-11 21:11 | 周旭

# re: FckEditor上传音频视频[未登录]  回复  更多评论   

请问为什么多媒体文件超过2M就上传不了呢??
请高手帮忙啊,谢谢,我的QQ是54243115
2009-04-27 11:17 | john

只有注册用户登录后才能发表评论。


网站导航: