I'm having trouble to display the preview of the video/image
being loaded
Basically I mean to say below code is not firing to get video/image
preview
It is my Jsfiddle
.bind('fileuploadprocessalways', function(e, data)
{
var canvas = data.files[0].preview;
var dataURL = canvas.toDataURL();
$("#some-image").css("background-image", 'url(' + dataURL +')');
})
Question: please help me to have preview of video/image
being uploaded
here is my complete code
html:
<input id="fileupload" type="file" name="files[]" multiple>
<div class="progress">
<div class="meter" style="width: 0%;"></div>
</div>
<div class="data"></div>
<div id="some-image"></div>
javascript:
$(function () {
$('#fileupload').fileupload({
url: '/echo/json/',
maxChunkSize: 1048576,
maxRetries: 3,
dataType: 'json',
multipart: false,
progressall: function (e, data) {
//progress
},
add: function (e, data) {
data.context = $('<p/>').text('Uploading...').appendTo('.data');
data.submit();
},
done: function (e, data) {
data.context.text('Upload finished.');
},
fail: function (e, data) {
data.context.text('Upload failed.');
}
}).bind('fileuploadprocessalways', function(e, data)
{
var canvas = data.files[0].preview;
var dataURL = canvas.toDataURL();
$("#some-image").css("background-image", 'url(' + dataURL +')');
})
});
Here is a sample how to capture video thumbnail using jQuery. The idea is to have fileupload, then load the video using
video
element set the video currentTime to some random time to get the thumbnail and draw the video usingcanvas
.To determines whether the specified media type can be played back you can use this code:
Possible values are:
"probably"
: The specified media type appears to be playable."maybe"
: Cannot tell if the media type is playable without playing it.""
: The specified media type definitely cannot be played.I think some thing like this.