选了个较简单的方法,在上传视频的功能里处理上传音乐
参考:https://segmentfault.com/a/1190000010364068
但上文方法不能同时上传音乐和视频,需要处理一下第一个方法:文件路径ueditor/dialog/video/video.js
/* 插入上传视频 */ function insertUpload() { var videoObjs = [], uploadDir = editor.getOpt(‘videoUrlPrefix’), width = parseInt( G ( ′ u p l o a d w i d t h ′ ) . v a l u e , 10 ) ∣ ∣ 420 , h e i g h t = p a r s e I n t ( G('upload_width').value, 10) || 420, height = parseInt( G(′uploadwidth′).value,10)∣∣420,height=parseInt(G(‘upload_height’).value, 10) || 280, align = findFocus(“upload_alignment”, “name”) || ‘none’; // for (var key in uploadVideoList) { // var file = uploadVideoList[key]; // videoObjs.push({ // url: uploadDir + file.url, // width: width, // height: height, // align: align // }); // } var count = uploadFile.getQueueCount(); // if (count) { // $(’.info’, ‘#queueList’).html(’’ + ‘还有2个未上传文件’.replace(/[\d]/, count) + ‘’); // return false; // } else { // editor.execCommand(‘insertvideo’, videoObjs, ‘upload’); // } if (count) { $(’.info’, ‘#queueList’).html(’’ + ‘还有2个未上传文件’.replace(/[\d]/, count) + ‘’); return false; } else { for (var key in uploadVideoList) { var is_music = 0; var file = uploadVideoList[key]; var ext = file.url.split(’.’).pop().toLowerCase(); var music_type = [‘mp3’, ‘wav’]; for (var i in music_type) { if (music_type[i] == ext) {
is_music = 1; }
} if (is_music) { editor.execCommand(‘music’, { url: uploadDir + file.url, width: 400, height: 95 }); } else { var file = uploadVideoList[key]; videoObjs.push({ url: uploadDir + file.url, width: width, height: height, align: align
}); editor.execCommand(‘insertvideo’, videoObjs, ‘upload’); }
}
}
}