在FCKeditor 2.6中添加插入视频和音频功能

本文转载

在FCKeditor 2.6中添加插入视频和音频功能

这里有两种方式,一是自己修改,二是使用插件

1.自己修改

      FCKeditor 是现在用的最多的可视编辑器,乐乎也是使用了该编辑器,应大家的要求,添加了插入视频和音频的功能,因为2.6版的修改可能和其他版本不一样,所以我把修改的地方列举出来,格式我是看到网上有位同志的格式很好,照抄的,内容已经修改

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

一、分别打开:editor/js/fckeditorcode_ie.js和/editor/js/fckeditorcode_gecko.js

 
找到程序代码

 

以下是代码片段:
Js代码 
  1. ||//.swf($|#|/?)/i.test(A.src)    
Js代码 
  1. ||//.swf($|#|/?)/i.test(A.src)    
这段代码的主要用来判断后缀名,如果后缀名不是swf则返回,把它替换为:

以下是代码片段:


Js代码 
  1. ||//.swf($|#|/?)/i.test(A.src)||//.mpg($|#|/?)/i.test(A.src)  
  2. ||//.asf($|#|/?)/i.test(A.src)||//.wma($|#|/?)/i.test(A.src)  
  3. ||//.wmv($|#|/?)/i.test(A.src)||//.avi($|#|/?)/i.test(A.src)  
  4. ||//.mov($|#|/?)/i.test(A.src)||//.mp3($|#|/?)/i.test(A.src)  
  5. ||//.rmvb($|#|/?)/i.test(A.src)||//.mid($|#|/?)/i.test(A.src)  
Js代码 
  1. ||//.swf($|#|/?)/i.test(A.src)||//.mpg($|#|/?)/i.test(A.src)  
  2. ||//.asf($|#|/?)/i.test(A.src)||//.wma($|#|/?)/i.test(A.src)  
  3. ||//.wmv($|#|/?)/i.test(A.src)||//.avi($|#|/?)/i.test(A.src)  
  4. ||//.mov($|#|/?)/i.test(A.src)||//.mp3($|#|/?)/i.test(A.src)  
  5. ||//.rmvb($|#|/?)/i.test(A.src)||//.mid($|#|/?)/i.test(A.src)  
文件格式可以根据情况来修改,但是注意要和其他的几个地方吻合
 
二、打开/editor/dialog/fck_flash/fck_flash.js
 
1、增加程序代码,这段代码用来判断后缀名

 

 

Js代码 
  1. function WinPlayer(url){  
  2. var r, re;  
  3. re = /.(avi|wmv|asf|wma|mid|mp3|mpg)$/i;  
  4. r = url.match(re);  
  5. return r;  
  6. }  
  7.    
  8. function RealPlayer(url){  
  9. var r, re;  
  10. re = /.(.rm|.ra|.rmvb|ram)$/i;  
  11. r = url.match(re);  
  12. return r;  
  13. }  
  14.    
  15. function QuickTime(url){  
  16. var r, re;  
  17. re = /.(mov|qt)$/i;  
  18. r = url.match(re);  
  19. return r;  
  20. }  
  21.    
  22. function FlashPlayer(url){  
  23. var r, re;  
  24. re = /.swf$/i;  
  25. r = url.match(re);  
  26. return r;  
  27. }  
Js代码 
  1. function WinPlayer(url){  
  2. var r, re;  
  3. re = /.(avi|wmv|asf|wma|mid|mp3|mpg)$/i;  
  4. r = url.match(re);  
  5. return r;  
  6. }  
  7.    
  8. function RealPlayer(url){  
  9. var r, re;  
  10. re = /.(.rm|.ra|.rmvb|ram)$/i;  
  11. r = url.match(re);  
  12. return r;  
  13. }  
  14.    
  15. function QuickTime(url){  
  16. var r, re;  
  17. re = /.(mov|qt)$/i;  
  18. r = url.match(re);  
  19. return r;  
  20. }  
  21.    
  22. function FlashPlayer(url){  
  23. var r, re;  
  24. re = /.swf$/i;  
  25. r = url.match(re);  
  26. return r;  
  27. }  
 
以下是代码片段:
 
2、替换程序代码,这段代码是在UpdatePreview中用来添加type属性
以下是代码片段:
Js代码 
  1. SetAttribute( e, 'type''application/x-shockwave-flash' ) ;  
Js代码 
  1. SetAttribute( e, 'type''application/x-shockwave-flash' ) ;  

 

 

Js代码 
  1. if(WinPlayer(GetE('txtUrl').value)!=null){  
  2. SetAttribute( e, 'type''application/x-mplayer2' ) ;  
  3. }  
  4. if(RealPlayer(GetE('txtUrl').value)!=null){  
  5. SetAttribute( e, 'type''audio/x-pn-realaudio-plugin' ) ;  
  6. }  
  7. if(QuickTime(GetE('txtUrl').value)!=null){  
  8. SetAttribute( e, 'type''application/video/quicktime' ) ;  
  9. }  
  10. if(FlashPlayer(GetE('txtUrl').value)!=null){  
  11. SetAttribute( e, 'type''application/x-shockwave-flash' ) ;  
  12. SetAttribute( e, 'pluginspage''http://www.macromedia.com/go/getflashplayer ' ) ;  
  13. }  
Js代码 
  1. if(WinPlayer(GetE('txtUrl').value)!=null){  
  2. SetAttribute( e, 'type''application/x-mplayer2' ) ;  
  3. }  
  4. if(RealPlayer(GetE('txtUrl').value)!=null){  
  5. SetAttribute( e, 'type''audio/x-pn-realaudio-plugin' ) ;  
  6. }  
  7. if(QuickTime(GetE('txtUrl').value)!=null){  
  8. SetAttribute( e, 'type''application/video/quicktime' ) ;  
  9. }  
  10. if(FlashPlayer(GetE('txtUrl').value)!=null){  
  11. SetAttribute( e, 'type''application/x-shockwave-flash' ) ;  
  12. SetAttribute( e, 'pluginspage''http://www.macromedia.com/go/getflashplayer ' ) ;  
  13. }  
 
以下是代码片段:
3、替换程序代码,这段代码是在UpdateEmbed中用来添加type属性

 

 

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

 

 

Js代码 
  1. if(WinPlayer(GetE('txtUrl').value)!=null){  
  2.     SetAttribute( e, 'type' , 'application/x-mplayer2' ) ;  
  3.     SetAttribute( e, 'autostart', GetE('chkAutoPlay').checked ? 'true' : 'false' ) ;  
  4. }  
  5. if(RealPlayer(GetE('txtUrl').value)!=null){  
  6.     SetAttribute( e, 'type' , 'audio/x-pn-realaudio-plugin' ) ;  
  7.     SetAttribute( e, 'autostart', GetE('chkAutoPlay').checked ? 'true' : 'false' ) ;  
  8. }  
  9. if(QuickTime(GetE('txtUrl').value)!=null){  
  10.     SetAttribute( e, 'type' , 'video/quicktime' ) ;  
  11.     SetAttribute( e, 'autostart', GetE('chkAutoPlay').checked ? 'true' : 'false' ) ;  
  12. }  
  13. if(FlashPlayer(GetE('txtUrl').value)!=null){  
  14.     SetAttribute( e, 'type' , 'application/x-shockwave-flash' ) ;  
  15.     SetAttribute( e, 'pluginspage' , 'http://www.macromedia.com/go/getflashplayer ' ) ;  
  16. }  
Js代码 
  1. if(WinPlayer(GetE('txtUrl').value)!=null){  
  2.     SetAttribute( e, 'type' , 'application/x-mplayer2' ) ;  
  3.     SetAttribute( e, 'autostart', GetE('chkAutoPlay').checked ? 'true' : 'false' ) ;  
  4. }  
  5. if(RealPlayer(GetE('txtUrl').value)!=null){  
  6.     SetAttribute( e, 'type' , 'audio/x-pn-realaudio-plugin' ) ;  
  7.     SetAttribute( e, 'autostart', GetE('chkAutoPlay').checked ? 'true' : 'false' ) ;  
  8. }  
  9. if(QuickTime(GetE('txtUrl').value)!=null){  
  10.     SetAttribute( e, 'type' , 'video/quicktime' ) ;  
  11.     SetAttribute( e, 'autostart', GetE('chkAutoPlay').checked ? 'true' : 'false' ) ;  
  12. }  
  13. if(FlashPlayer(GetE('txtUrl').value)!=null){  
  14.     SetAttribute( e, 'type' , 'application/x-shockwave-flash' ) ;  
  15.     SetAttribute( e, 'pluginspage' , 'http://www.macromedia.com/go/getflashplayer ' ) ;  
  16. }  
 
以下是代码片段:

三、打开/fckconfig.js,该文件为配置文件

替换程序代码,这个是在上传文件的时候检查后缀名

以下是代码片段:
Js代码 
  1. FCKConfig.FlashUploadAllowedExtensions = ".(swf)$" ; // empty for all  
Js代码 
  1. FCKConfig.FlashUploadAllowedExtensions = ".(swf)$" ; // empty for all  
以下是代码片段:
Js代码 
  1. FCKConfig.FlashUploadAllowedExtensions   
  2.     = ".(swf|fla|mpg|asf|wma|wmv|avi|mov|mp3|rmvb|mid)$" ; // empty for all  
Js代码 
  1. FCKConfig.FlashUploadAllowedExtensions   
  2.     = ".(swf|fla|mpg|asf|wma|wmv|avi|mov|mp3|rmvb|mid)$" ; // empty for all  

三、打开/editor/lang/zh-cn.js 文件,该部分为语言文件,Flash替换掉就可以了

然后整体修改完成,现在lehu已经支持上传视频和音频文件,不过注意的是,如果视频文件太大,还是可能出现不能播放的情况

四、还需要在fckeditor.properties文件里加上(使用fckeditor2.6.3,fckeditor-java2.4)

Java代码 
  1. connector.resourceType.flash.extensions.allowed   
  2.       = swf|fla|mpg|asf|wma|wmv|avi|mov|mp3|rmvb|mid  
Java代码 
  1. connector.resourceType.flash.extensions.allowed   
  2.       = swf|fla|mpg|asf|wma|wmv|avi|mov|mp3|rmvb|mid  
 
2.插件 
这里介绍一个FCK的插件,多媒体插件,支持Windows Media,Real,QuickTime,Flash,
Shockwave,完全可以替换FCK自带的flash插入功能。
前段时间在发过一篇《利用Fckeditor插入MP3或视频文件》,是通过修改FCK的Flash插入实现插入多媒体的,和这里的插件原理是一样的。
插件的具体使用方法如下:
1、解压文件到 FCKeditor/editor/plugins,命名为Media
- 隐藏引用文字 -
2、修改配置文件 FCKeditor/fckconfig.js ,包括启用插件和添加按钮。
JavaScript代码
Js代码 
  1. FCKConfig.PluginsPath = FCKConfig.BasePath + 'plugins/' ;         //找到这一句,配置插件路径  
  2. FCKConfig.Plugins.Add( 'Media''en,zh,zh-cn' ) ;  //启用插件  
  3.     
  4. …………  //中间代码省略  
  5.     
  6. FCKConfig.ToolbarSets["Default"] = [    
  7.     ['Source','Templates'],    
  8.     ['FontName','FontSize'],    
  9.     ['TextColor','BGColor'],    
  10.     ['Image','Flash'],  //可以用Media替换Flash  
  11.     ['Table','Rule'],    
  12.     ['FitWindow','ShowBlocks'],    
  13.    ['Smiley','SpecialChar','Media'], //或者加入Media按钮  
  14.     '/',    
  15.     ['PasteText','PasteWord','RemoveFormat'],    
  16.     ['Undo','Redo','Find','Replace'],    
  17.     ['Bold','Italic','Underline','StrikeThrough'],    
  18.     ['OrderedList','UnorderedList','-','Outdent','Indent','Blockquote'],    
  19.     ['JustifyLeft','JustifyCenter','JustifyRight'],    
  20.     ['Anchor','Link','Unlink'//我的按钮的配置,可能和你的不太一样  
  21. ] ;    
Js代码 
  1. FCKConfig.PluginsPath = FCKConfig.BasePath + 'plugins/' ;         //找到这一句,配置插件路径  
  2. FCKConfig.Plugins.Add( 'Media''en,zh,zh-cn' ) ;  //启用插件  
  3.     
  4. …………  //中间代码省略  
  5.     
  6. FCKConfig.ToolbarSets["Default"] = [    
  7.     ['Source','Templates'],    
  8.     ['FontName','FontSize'],    
  9.     ['TextColor','BGColor'],    
  10.     ['Image','Flash'],  //可以用Media替换Flash  
  11.     ['Table','Rule'],    
  12.     ['FitWindow','ShowBlocks'],    
  13.    ['Smiley','SpecialChar','Media'], //或者加入Media按钮  
  14.     '/',    
  15.     ['PasteText','PasteWord','RemoveFormat'],    
  16.     ['Undo','Redo','Find','Replace'],    
  17.     ['Bold','Italic','Underline','StrikeThrough'],    
  18.     ['OrderedList','UnorderedList','-','Outdent','Indent','Blockquote'],    
  19.     ['JustifyLeft','JustifyCenter','JustifyRight'],    
  20.     ['Anchor','Link','Unlink'//我的按钮的配置,可能和你的不太一样  
  21. ] ;    
 
找到类似代码添加如下内容
Js代码 
  1. FCKConfig.MediaUpload = true ;  
  2. FCKConfig.MediaUploadURL = FCKConfig.BasePath + 'filemanager/connectors/' +   
  3.        _QuickUploadLanguage + '/upload.' + _QuickUploadLanguage + '?Type=Media' ;  
  4. FCKConfig.MediaUploadAllowedExtensions = ".(avi|asf)$" ;  // empty for all  
  5. FCKConfig.MediaUploadDeniedExtensions = "" ;       // empty for no one  
Js代码 
  1. FCKConfig.MediaUpload = true ;  
  2. FCKConfig.MediaUploadURL = FCKConfig.BasePath + 'filemanager/connectors/' +   
  3.        _QuickUploadLanguage + '/upload.' + _QuickUploadLanguage + '?Type=Media' ;  
  4. FCKConfig.MediaUploadAllowedExtensions = ".(avi|asf)$" ;  // empty for all  
  5. FCKConfig.MediaUploadDeniedExtensions = "" ;       // empty for no one  
  
下载地址: http://dev.fckeditor.net/ticket/382

最近做了一个文章管理的系统,用到在线编辑器,修改了一下现在能实现音频视频,图片,附件,Flash等文件的上传。费了好大的功夫。。 FCKeditor应用在ASP.NET上,需要两组文件,一组是FCKeditor本身,另一个是用于ASP.NET的FCKeditor控件(分为1.12.0两个版本,这里使用2.0版本)。 1.FCKeditor加入到项目中 解压FCKeditor编辑器,得到文件夹fckeditor,复制此文件夹到Web应用的项目下(也可以是子孙目录下)。 解压FCKeditor控件,在其子目录bin/Release/2.0下有一个程序集。在Web应用的项目中引用该程序集。 2. 在页面中使用FCKeditor 有两种方式。 (1)手工编码 在页面中加入ASP.NET指令: 然后在需要的地方加入FCKeditor控件: (2)集成到Visual Studio工具箱 打开一ASP.NET页面,展开Toolbox,打开右键菜单,选择“Choose Items ...”,在出现的“Choose Toolbox Items”会话框的“.NET Framework Components”选项卡中选择“Browse”,找到并选中FCKeditor程序集,打开后回到“Choose Toolbox Items”窗口,点击“OK”,完成控件导入。 这时,在Toolbox的General分类下出现了一个名为FCKeditor的控件,可以像使用Visual Studio内置控件一样使用它。 3. 配置FCKeditor编辑器路径 在页面中,使用的是FCKeditor控件,该控件需要知道FCKeditor编辑器文件组的路径。有两种配置方法。 (1)配置web.config 在appSettings配置节中加入 使用这种配置方法后,对于项目中任何一个页面中用到的FCKeditor控件,都不用再配置其BasePath属性。 (2)直接对用到的FCKeditor控件进行配置 在页面代码中设置FCKeditor的属性BasePath为FCKeditor编辑器文件组的路径,或者在Page_Init事件处理器中设置其BasePath的值。 4. 配置FCKeditor编辑器文件上传路径 在web.config的appSettings配置节中加入 或者 这样,就完成了FCKeditor向ASP.NET页面的集成工作。 二、配置FCKeditor 按照FCKeditor的默认配置,可以完成一些常用的HTML可视化编辑工作,但在实际应用中,还需要对其做进一步的配置。FCKeditor控件的可配置属性不多,且配置后只能作用于一个单一实例。实际上,需要对FCKeditor编辑器文件组中的通用配置文件/fckconfig.jsASP.NET专用文件上传管理代码文件/editor/filemanager/connectors/aspx/config.ascx进行配置。 1. 配置控件语言 FCKeditor是自动探测浏览器所使用的语言编码的,其默认语言是英文。修改配置行"FCKConfig.DefaultLanguage = 'en';"为'zh-cn',采用中文为默认语言。 2. 配置控件应用技术 FCKeditor默认是用于php技术的。修改配置行"var _FileBrowserLanguage = 'php';""var _
兼容目前的浏览器 里面包含FCKeditor编辑器控件 一、集成方法 FCKeditor应用在ASP.NET上,需要两组文件,一组是FCKeditor本身,另一个是用于ASP.NET的FCKeditor控件(分为1.12.0两个版本,这里使用2.0版本)。 1.FCKeditor加入到项目中 解压FCKeditor编辑器,得到文件夹fckeditor,复制此文件夹到Web应用的项目下(也可以是子孙目录下)。 解压FCKeditor控件,在其子目录bin/Release/2.0下有一个程序集。在Web应用的项目中引用该程序集。 2. 在页面中使用FCKeditor 有两种方式。 (1)手工编码 在页面中加入ASP.NET指令: 然后在需要的地方加入FCKeditor控件: (2)集成到Visual Studio工具箱 打开一ASP.NET页面,展开Toolbox,打开右键菜单,选择“Choose Items ...”,在出现的“Choose Toolbox Items”会话框的“.NET Framework Components”选项卡中选择“Browse”,找到并选中FCKeditor程序集,打开后回到“Choose Toolbox Items”窗口,点击“OK”,完成控件导入。 这时,在Toolbox的General分类下出现了一个名为FCKeditor的控件,可以像使用Visual Studio内置控件一样使用它。 3. 配置FCKeditor编辑器路径 在页面中,使用的是FCKeditor控件,该控件需要知道FCKeditor编辑器文件组的路径。有两种配置方法。 (1)配置web.config 在appSettings配置节中加入 使用这种配置方法后,对于项目中任何一个页面中用到的FCKeditor控件,都不用再配置其BasePath属性。 (2)直接对用到的FCKeditor控件进行配置 在页面代码中设置FCKeditor的属性BasePath为FCKeditor编辑器文件组的路径,或者在Page_Init事件处理器中设置其BasePath的值。 4. 配置FCKeditor编辑器文件上传路径 在web.config的appSettings配置节中加入 这样,就完成了FCKeditor向ASP.NET页面的集成工作。 二、配置FCKeditor 按照FCKeditor的默认配置,可以完成一些常用的HTML可视化编辑工作,但在实际应用中,还需要对其做进一步的配置。FCKeditor控件的可配置属性不多,且配置后只能作用于一个单一实例。实际上,需要对FCKeditor编辑器文件组中的通用配置文件/fckconfig.jsASP.NET专用文件上传管理代码文件/editor/filemanager/connectors/aspx/config.ascx进行配置。 1. 配置控件语言 FCKeditor是自动探测浏览器所使用的语言编码的,其默认语言是英文。修改配置行"FCKConfig.DefaultLanguage = 'en';"为'zh-cn',采用中文为默认语言。 2. 配置控件应用技术 FCKeditor默认是用于php技术的。修改配置行"var _FileBrowserLanguage = 'php';""var _QuickUploadLanguage = 'php';"为'aspx',采用ASP.NET技术。 3. 配置Tab键 默认Tab键在FCKeditor中不可用,可以修改配置行"FCKConfig.TabSpaces = 0;"为1,启用Tab键。 4. 定制FCKe
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值