本文是针对ueditor视频上传后,无法在编辑框中播放的问题进行探讨,主要还是对网友所使用的的解决方法的实践和修改。
问题1 ueditor插入第三方视频链接不显示,输入视频地址有误
各位可以参考这个博客的文章https://blog.csdn.net/xxf_fighting/article/details/88415723
参考这篇博客,对ueditor/dialogs/video/video.js文件**createPreviewVideo()**方法里,删除
<embed>
其中的type类型(type=“application/x-shockwave-flash”)
问题2 ueditor插入视频后无法播放
将ueditor.all.js文件中约17783行代码( 可以通过搜索creatInsertStr定位)由 html.push(creatInsertStr( vi.url, vi.width || 420, vi.height || 280, id + i, null, cl, ‘image’));
修改为
html.push(creatInsertStr( vi.url, vi.width || 420, vi.height || 280, id + i, null, cl, ‘video’));
问题3 ueditor插入视频后再次编辑无法播放
问题2中进行了插入视频的播放,但是插入视频,数据保存到后台之后,再次编辑,会发现文本框中的视频无法回显如下图。因为ueditor源码这里是两个不同的代码控制实现的。所以针对内容编辑,视频回显,还需要在进行源码修改。
这种情况两种解决方法
1.修改ueditor.all.js文件中switchImgAndVideo方法
第二个if语句里三元判断全部改成video,因为你会发现出现上图内容,是因为某种原因,ueditor将其渲染为了img,这时我们只能强制将他判断为video。
function switchImgAndVideo(root,img2video){
utils.each(root.getNodesByTagName(img2video ? 'img' : 'embed video'),function(node){
var className = node.getAttr('class');
if(className && className.indexOf('edui-faked-video') != -1){
var html = creatInsertStr( img2video ? node.getAttr('_url') : node.getAttr('src'