//引入Plupload hideShowContent.js後var is_upload_video = 0;var is_upload_img = 0;var Qiniu = new QiniuJsSDK();var uploader = Qiniu.uploader({runtimes: 'html5,flash,html4', //上傳模式,依次退化browse_button: 'pickfiles', //上傳選擇的點選按鈕,**必需**uptoken_url: '__ROOT__/qiniu/get_up_token?key={$path}&bucket_type=video', //Ajax請求upToken的Url,**強烈建議設定**(服務端提供)//uptoken : '', //若未指定uptoken_url,則必須指定 uptoken ,uptoken由其他程式產生//unique_names: true, // 預設 false,key為檔案名稱。若開啟該選項,SDK為自動產生上傳成功後的key(檔案名稱)。//save_key: true, // 預設 false。若在服務端產生uptoken的上傳策略中指定了 `sava_key`,則開啟,SDK會忽略對key的處理domain: '{$video_domian}', //bucket 網域名稱,下載資源時用到,**必需**container: 'container',//上傳地區DOM ID,預設是browser_button的父元素,max_file_size: '60mb', //最大檔案體積限制flash_swf_url: 'Public/js/plupload/Moxie.swf', //引入flash,相對路徑max_retries: 1, //上傳失敗最大重試次數dragdrop: true, //開啟可拖曳上傳drop_element: 'container',//拖曳上傳地區元素的ID,拖曳檔案或檔案夾後可觸發上傳chunk_size: '4mb', //分塊上傳時,每片的體積auto_start: true, //選擇檔案後自動上傳,若關閉需要自己綁定事件觸發上傳init: {'FilesAdded': function(up, files) {plupload.each(files, function(file) {// 檔案添加進隊列後,處理相關的事情upload_pics_number++;$('font_video').show();if (upload_pics_number = 1) {$('#Support').hide();}});},'BeforeUpload': function(up, file) {//設定上傳檔案的格式和大小;$array = ['video/mp4','video/avi','video/mpg','image/gif'];if(-1 == jQuery.inArray( file.type, $array )){alert("上傳檔案格式不正確")window.location.reload();return false;}if (file.size > 50 * 1024 * 1024) {alert('上傳檔案大小不能大於50M')window.location.reload();return false;}is_upload_video = 1;$('#fsUploadProgressBox').show();$('#videoBox').hide()},'UploadProgress': function(up, file) {var progress = new FileProgress(file, 'fsUploadProgress');var chunk_size = plupload.parseSize(this.getOption('chunk_size'));progress.setProgress(file.percent + "%", up.total.bytesPerSec, chunk_size);},'FileUploaded': function(up, file, info) { $('#fsUploadProgressBox').hide(); console.log(info);var dataObj = eval("("+info+")");if(dataObj.success == 'true') {$.getJSON("__ROOT__/qiniu/get_video_pic_url?key={$path}&bucket_type=pics",function(json){$('#video_thumbnail_input').val(json.key);$('#Support').show();$('#product_video_qn').val('{$path}');$('font_video').hide();$('#preview_video').attr('href', "__ROOT__/product/video_show?video_stream=__ROOT__/qiniu/get_video_url?key={$path}&is_redirect=1").show();is_upload_video = 0;});} else {alert("上傳失敗,請重新上傳");$('#Support').show();$('font_video').show();return false;}},'Error': function(up, err, errTip) {//上傳出錯時,處理相關的事情$('font_video').show();$('#Support').show();alert(errTip);},'UploadComplete': function() {$('#fsUploadProgressBox').hide(); //隊列檔案處理完畢後,處理相關的事情$('#videoBox').html('上傳完成');chunk_index = 0;},'Key': function(up, file) {// 若想在前端對每個檔案的key進行個人化處理,可以配置該函數// 該配置必須要在 unique_names: false , save_key: false 時才生效var key = "{$path}";// do something with key herereturn key}}});
回複內容:
//引入Plupload hideShowContent.js後var is_upload_video = 0;var is_upload_img = 0;var Qiniu = new QiniuJsSDK();var uploader = Qiniu.uploader({runtimes: 'html5,flash,html4', //上傳模式,依次退化browse_button: 'pickfiles', //上傳選擇的點選按鈕,**必需**uptoken_url: '__ROOT__/qiniu/get_up_token?key={$path}&bucket_type=video', //Ajax請求upToken的Url,**強烈建議設定**(服務端提供)//uptoken : '', //若未指定uptoken_url,則必須指定 uptoken ,uptoken由其他程式產生//unique_names: true, // 預設 false,key為檔案名稱。若開啟該選項,SDK為自動產生上傳成功後的key(檔案名稱)。//save_key: true, // 預設 false。若在服務端產生uptoken的上傳策略中指定了 `sava_key`,則開啟,SDK會忽略對key的處理domain: '{$video_domian}', //bucket 網域名稱,下載資源時用到,**必需**container: 'container',//上傳地區DOM ID,預設是browser_button的父元素,max_file_size: '60mb', //最大檔案體積限制flash_swf_url: 'Public/js/plupload/Moxie.swf', //引入flash,相對路徑max_retries: 1, //上傳失敗最大重試次數dragdrop: true, //開啟可拖曳上傳drop_element: 'container',//拖曳上傳地區元素的ID,拖曳檔案或檔案夾後可觸發上傳chunk_size: '4mb', //分塊上傳時,每片的體積auto_start: true, //選擇檔案後自動上傳,若關閉需要自己綁定事件觸發上傳init: {'FilesAdded': function(up, files) {plupload.each(files, function(file) {// 檔案添加進隊列後,處理相關的事情upload_pics_number++;$('font_video').show();if (upload_pics_number = 1) {$('#Support').hide();}});},'BeforeUpload': function(up, file) {//設定上傳檔案的格式和大小;$array = ['video/mp4','video/avi','video/mpg','image/gif'];if(-1 == jQuery.inArray( file.type, $array )){alert("上傳檔案格式不正確")window.location.reload();return false;}if (file.size > 50 * 1024 * 1024) {alert('上傳檔案大小不能大於50M')window.location.reload();return false;}is_upload_video = 1;$('#fsUploadProgressBox').show();$('#videoBox').hide()},'UploadProgress': function(up, file) {var progress = new FileProgress(file, 'fsUploadProgress');var chunk_size = plupload.parseSize(this.getOption('chunk_size'));progress.setProgress(file.percent + "%", up.total.bytesPerSec, chunk_size);},'FileUploaded': function(up, file, info) { $('#fsUploadProgressBox').hide(); console.log(info);var dataObj = eval("("+info+")");if(dataObj.success == 'true') {$.getJSON("__ROOT__/qiniu/get_video_pic_url?key={$path}&bucket_type=pics",function(json){$('#video_thumbnail_input').val(json.key);$('#Support').show();$('#product_video_qn').val('{$path}');$('font_video').hide();$('#preview_video').attr('href', "__ROOT__/product/video_show?video_stream=__ROOT__/qiniu/get_video_url?key={$path}&is_redirect=1").show();is_upload_video = 0;});} else {alert("上傳失敗,請重新上傳");$('#Support').show();$('font_video').show();return false;}},'Error': function(up, err, errTip) {//上傳出錯時,處理相關的事情$('font_video').show();$('#Support').show();alert(errTip);},'UploadComplete': function() {$('#fsUploadProgressBox').hide(); //隊列檔案處理完畢後,處理相關的事情$('#videoBox').html('上傳完成');chunk_index = 0;},'Key': function(up, file) {// 若想在前端對每個檔案的key進行個人化處理,可以配置該函數// 該配置必須要在 unique_names: false , save_key: false 時才生效var key = "{$path}";// do something with key herereturn key}}});
關於視頻的介面你可以參考:
http://developer.qiniu.com/docs/v6/api/reference/fop/av/vframe.html
vframe 是同步的fop。
比如對於視頻:http://rwxf.qiniudn.com/1.mp4
第五秒的外鏈是:http://rwxf.qiniudn.com/1.mp4?vframe/png/offset/5