我正在尝试使用jquery文件上传插件和videojs-record插件来捕获用户录制并将其上传到服务器。
一切正常,JS确实创建了一个blob,但文件不会上传。
这是我的代码:
$(function () {
// Initialize the jQuery File Upload widget
$('#fileupload').fileupload({
url: '/php',
done: function (e, data) {
$.each(data.files, function (index, file) {
var message = 'Upload complete: ' + file.name + ' (' +
file.size + ' bytes)';
$('<p/>').text(message).appendTo(document.body);
console.log(message);
});
}
});
// setup videojs-record
var player = videojs('myAudio',
{
controls: true,
width: 600,
height: 300,
plugins: {
record: {
audio: true,
video: true,
maxLength: 20,
debug: true
}
}
});
player.on('finishRecord', function()
{
// the blob object contains the audio data
var audioFile = player.recordedData;
console.log('finished recording: ', audioFile);
// upload data to server
var filesList = [audioFile.video];
$('#fileupload').fileupload('add', {files: filesList});
});
});