etranmedia.js 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. (function() {
  2. CKEDITOR.dialog.add("etranmedia",
  3. function(ecmseditorv) {
  4. return {
  5. title: "插入视频",
  6. minWidth: "500",
  7. minHeight:"400",
  8. contents: [{
  9. id: "etmediainfo1",
  10. label: "常规",
  11. title: "常规",
  12. expand: true,
  13. width: "500px",
  14. height: "400px",
  15. padding: 0,
  16. elements: [
  17. {type:"hbox",widths:["90%","10%"],align:"right",children:[
  18. {id:"etmediaurl",type:"text",label:"<strong>视频地址</strong> ",style:"width:100%;float:left;","default":""}
  19. ,{type:"button",id:"browse",filebrowser:{action:"Browse",target:"etmediainfo1:etmediaurl",url:ecmseditorv.config.filebrowserFlashUploadUrl+'FileMain.php?'+ecmseditorv.config.filebrowserImageBrowseUrl+'&doecmspage=TranMedia&type=3&tranfrom=1&field=&InstanceId='+ecmseditorv.id+'&InstanceName='+ecmseditorv.name},style:"display:inline-block;margin-top:14px;",hidden:!0,label:"选择"}]},
  20. {type:"hbox",widths:["25%","25%","25%","25%"],align:"right",children:[
  21. {id:"etmediawidth",type:"text",label:"宽度",style:"width:100%;float:left","default":"480"},
  22. {id:"etmediaheight",type:"text",label:"高度",style:"width:100%;float:left","default":"360"},
  23. {
  24. id: 'etmediatoplay',
  25. type: 'select',
  26. label: '播放器',
  27. items: [
  28. [ '自动识别', '0' ],
  29. [ 'HTML5Video', '5' ],
  30. [ 'HTML5Audio', '6' ],
  31. [ 'Media Player', '1' ],
  32. [ 'Real Player', '2' ],
  33. [ 'Flv Player', '3' ],
  34. [ 'Flash Player', '4' ]
  35. ]
  36. },
  37. {
  38. id: 'etmediaplaymod',
  39. type: 'select',
  40. label: '播放模式',
  41. items: [
  42. [ '自动播放', '0' ],
  43. [ '手动播放', '1' ]
  44. ]
  45. }
  46. ]},
  47. {type:"html",id:"preview",style:"width:100%;",html:"<div><strong>"+CKEDITOR.tools.htmlEncode(ecmseditorv.lang.common.preview)+
  48. "</strong>:<a onclick=etmediaview('cke_MediaPreviewBox_"+ecmseditorv.name+"');>[点击这里显示预览]</a><br><div id='cke_MediaPreviewBox_"+ecmseditorv.name+"' class='MediaPreviewBox'></div></div>"}
  49. ]
  50. },
  51. {id:"Upload",label:ecmseditorv.lang.image.upload,elements:[
  52. {
  53. type: "html",
  54. style: "width:500;height:250",
  55. html: ' <IFRAME frameBorder="0" id="edtmedia'+ecmseditorv.name+'" name="edtmedia'+ecmseditorv.name+'" scrolling="auto" src="'+ecmseditorv.config.filebrowserFlashUploadUrl+'editorpage/ecmseditorpage.php?'+ecmseditorv.config.filebrowserFlashBrowseUrl+'&doecmspage=TranMedia&type=3&InstanceId='+ecmseditorv.id+'&InstanceName='+ecmseditorv.name+'&CKEditorFuncNum='+ecmseditorv._.filebrowserFn+'&langCode='+ecmseditorv.langCode+'" style="HEIGHT:250px;VISIBILITY:inherit;WIDTH:100%;Z-INDEX:2"></IFRAME>'
  56. }
  57. ]},
  58. ],
  59. onOk: function() {
  60. var ehtmlstr='';
  61. var emediaurl=this.getValueOf('etmediainfo1','etmediaurl');
  62. var ewidth=this.getValueOf('etmediainfo1','etmediawidth');
  63. var eheight=this.getValueOf('etmediainfo1','etmediaheight');
  64. var etoplay=this.getValueOf('etmediainfo1','etmediatoplay');
  65. var eplaymod=this.getValueOf('etmediainfo1','etmediaplaymod');
  66. ehtmlstr=etmediaViewFile(emediaurl,ewidth,eheight,etoplay,eplaymod);
  67. //点击确定按钮后的操作
  68. ecmseditorv.insertHtml(ehtmlstr);
  69. document.getElementById('cke_MediaPreviewBox_'+ecmseditorv.name).innerHTML='';
  70. },
  71. onCancel: function() {
  72. document.getElementById('cke_MediaPreviewBox_'+ecmseditorv.name).innerHTML='';
  73. }
  74. }
  75. })
  76. })();
  77. //预览
  78. function etmediaview(viewid){
  79. var ehtmlstr='';
  80. var emediaurl=CKEDITOR.dialog.getCurrent().getContentElement('etmediainfo1','etmediaurl').getValue();
  81. var ewidth=CKEDITOR.dialog.getCurrent().getContentElement('etmediainfo1','etmediawidth').getValue();
  82. var eheight=CKEDITOR.dialog.getCurrent().getContentElement('etmediainfo1','etmediaheight').getValue();
  83. var etoplay=CKEDITOR.dialog.getCurrent().getContentElement('etmediainfo1','etmediatoplay').getValue();
  84. var eplaymod=CKEDITOR.dialog.getCurrent().getContentElement('etmediainfo1','etmediaplaymod').getValue();
  85. ehtmlstr=etmediaViewFile(emediaurl,ewidth,eheight,etoplay,eplaymod);
  86. document.getElementById(viewid).innerHTML=ehtmlstr;
  87. }
  88. //返回播放器代码
  89. function etmediaViewFileCode(toplay,width,height,autostart,furl){
  90. var fname='';
  91. var addauto='';
  92. if(autostart=="true")
  93. {
  94. addauto=' autoplay="autoplay"';
  95. }
  96. if(toplay==1)//media
  97. {
  98. imgstr="<object align=middle classid=\"CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95\" class=\"OBJECT\" id=\"MediaPlayer\" width=\""+width+"\" height=\""+height+"\"><PARAM NAME=\"AUTOSTART\" VALUE=\""+autostart+"\"><param name=\"ShowStatusBar\" value=\"-1\"><param name=\"Filename\" value=\""+furl+"\"><embed type=\"application/x-oleobject codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701\" flename=\"mp\" src=\""+furl+"\" width=\""+width+"\" height=\""+height+"\"></embed></object>";
  99. }
  100. else if(toplay==5)//html5video
  101. {
  102. imgstr='<video id="ecmsvideoid" width="'+width+'" height="'+height+'" controls="controls"'+addauto+'><source src="'+furl+'"></source> Your browser is not supported </video>';
  103. }
  104. else if(toplay==6)//html5audio
  105. {
  106. imgstr='<audio id="ecmsaudioid" src="'+furl+'" controls="controls"'+addauto+'> Your browser is not supported </audio>';
  107. }
  108. else if(toplay==3)//flv
  109. {
  110. imgstr="<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\""+width+"\" height=\""+height+"\"><param name=\"movie\" value=\"/e/data/images/flvplayer.swf?vcastr_file="+furl+"&vcastr_title="+fname+"&BarColor=0xFF6600&BarPosition=1&IsAutoPlay="+autostart+"\"><param name=\"quality\" value=\"high\"><param name=\"allowFullScreen\" value=\"true\" /><embed src=\"/e/data/images/flvplayer.swf?vcastr_file="+furl+"&vcastr_title="+fname+"&BarColor=0xFF6600&BarPosition=1&IsAutoPlay="+autostart+"\" allowFullScreen=\"true\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+width+"\" height=\""+height+"\"></embed></object>";
  111. }
  112. else if(toplay==4)//flash
  113. {
  114. imgstr="<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\""+width+"\" height=\""+height+"\"><param name=\"movie\" value=\""+furl+"\"><param name=\"quality\" value=\"high\"><embed src=\""+furl+"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+width+"\" height=\""+height+"\"><param name=\"autoplay\" value=\""+autostart+"\" /></embed></object>";
  115. }
  116. else//reaplayer
  117. {
  118. imgstr="<object classid=\"clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA\" HEIGHT=\""+height+"\" ID=\"Player\" WIDTH=\""+width+"\" VIEWASTEXT><param NAME=\"_ExtentX\" VALUE=\"12726\"><param NAME=\"_ExtentY\" VALUE=\"8520\"><param NAME=\"AUTOSTART\" VALUE=\""+autostart+"\"><param NAME=\"SHUFFLE\" VALUE=\"0\"><param NAME=\"PREFETCH\" VALUE=\"0\"><param NAME=\"NOLABELS\" VALUE=0><param NAME=CONTROLS VALUE=ImageWindow><param NAME=CONSOLE VALUE=_master><param NAME=LOOP VALUE=0><param NAME=NUMLOOP VALUE=0><param NAME=CENTER VALUE=0><param NAME=MAINTAINASPECT VALUE=\""+furl+"\"><param NAME=BACKGROUNDCOLOR VALUE=\"#000000\"></object><br><object CLASSID=\"clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA\" HEIGHT=32 ID=\"Player\" WIDTH=\""+width+"\" VIEWASTEXT><param NAME=_ExtentX VALUE=18256><param NAME=_ExtentY VALUE=794><param NAME=AUTOSTART VALUE=\""+autostart+"\"><param NAME=SHUFFLE VALUE=0><param NAME=PREFETCH VALUE=0><param NAME=NOLABELS VALUE=0><param NAME=CONTROLS VALUE=controlpanel><param NAME=CONSOLE VALUE=_master><param NAME=LOOP VALUE=0><param NAME=NUMLOOP VALUE=0><param NAME=CENTER VALUE=0><param NAME=MAINTAINASPECT VALUE=0><param NAME=BACKGROUNDCOLOR VALUE=\"#000000\"><param NAME=SRC VALUE=\""+furl+"\"></object>";
  119. }
  120. return imgstr;
  121. }
  122. //返回
  123. function etmediaViewFile(furl,width,height,toplay,playmod){
  124. var imgstr="";
  125. var autostart;
  126. var mediatypes=",.wmv,.asf,.wma,.mp3,.asx,.mid,.midi,";
  127. var realtypes=",.rm,.ra,.rmvb,.mp4,.mov,.avi,.wav,.ram,.mpg,.mpeg,";
  128. var html5types=",.mp4,.ogg,.webm,";
  129. var html5audiotypes=",.mp3,.ogg,.wav,";
  130. var filetype;
  131. if(furl=='')
  132. {
  133. return '';
  134. }
  135. autostart="true";
  136. if(playmod==1)
  137. {
  138. autostart="false";
  139. }
  140. if(toplay==0)
  141. {
  142. filetype=etmediaToGetFiletype(furl);
  143. if(filetype=='.flv')
  144. {
  145. toplay=3;
  146. }
  147. else if(html5types.indexOf(','+filetype+',')!=-1)
  148. {
  149. toplay=5;
  150. }
  151. else if(html5audiotypes.indexOf(','+filetype+',')!=-1)
  152. {
  153. toplay=6;
  154. }
  155. else if(filetype=='.swf')
  156. {
  157. toplay=4;
  158. }
  159. else if(mediatypes.indexOf(','+filetype+',')!=-1)
  160. {
  161. toplay=1;
  162. }
  163. else
  164. {
  165. toplay=2;
  166. }
  167. }
  168. imgstr=etmediaViewFileCode(toplay,width,height,autostart,furl);
  169. return imgstr;
  170. }
  171. function etmediaToGetFiletype(sfile){
  172. var filetype,s;
  173. s=sfile.lastIndexOf(".");
  174. filetype=sfile.substring(s+1).toLowerCase();
  175. return '.'+filetype;
  176. }
  177. function EHEcmsEditorDoTranMedia(str){
  178. CKEDITOR.dialog.getCurrent().getContentElement('etmediainfo1','etmediaurl').setValue(str);
  179. CKEDITOR.dialog.getCurrent().selectPage('etmediainfo1');
  180. }