1. 程式人生 > >ppt轉flash kindeditor上傳視訊全屏問題

ppt轉flash kindeditor上傳視訊全屏問題

最近要增加頁面的ppt顯示功能,於是考慮把ppt轉成flash,在網上搜到了ispingfree,連結: https://pan.baidu.com/s/1QZzx6qmdsnwzWCuULXzUOw提取碼: e25c 

用了下果然可以把ppt轉成swf檔案,接下來就是上傳並在前臺顯示了,後臺的新聞編輯器是kindeditor,用kindeditor上傳視訊後發現無法實現全屏於是開始分析,發現kindeditor上傳視訊時會生成embed標籤

  <embed src="/jgsyzx/attached/media/20181113/20181113191524_639.swf" type="
application/x-shockwave-flash" width="550" height="400" autostart="false" loop="true" >

但是這個embed標籤沒有allowFullScreen屬性,一種想法是生成頁面後在頁面中使用jquery對embed標籤新增allowFullScreen=true,另一種是後臺儲存到資料庫之前新增.第一種想法嘗試過之後,發現不成功,不知道是不是因為瀏覽器的安全限制.於是嘗試第二張想法,使用jsoup對生成的embed標籤新增allowFullScreen屬性

 1 /*解析embed標籤,加入控制全屏屬性*/
2 private void setFullScreen(News news) { 3 String content = news.getContent(); 4 Document doc = Jsoup.parse(content); 5 Elements elements = doc.getElementsByTag("embed"); 6 if(elements != null) { 7 Element embed = elements.first(); 8 if
(embed != null) { 9 embed.attr("allowFullScreen","true"); 10 } 11 }else { 12 return; 13 } 14 news.setContent(doc.toString()); 15 }

這種想法經檢測是可行的