选了个较简单的方法,在上传视频的功能里处理上传音乐
参考:https://segmentfault.com/a/1190000010364068
但上文方法不能同时上传音乐和视频,需要处理一下第一个方法:文件路径ueditor/dialog/video/video.js
/* 插入上传视频 */ function insertUpload() { var videoObjs = [], uploadDir = editor.getOpt('videoUrlPrefix'), width = 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('<span style="color:red;">' + '还有2个未上传文件'.replace(/[\d]/, count) + '</span>'); 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'); }
}
}
}