本文介紹視頻類WVVideo相關的JSAPI,供您建立H5端應用或者小程式時參考。視頻類WVVideo相關JSAPI提供從相簿選擇視頻或調用相機拍攝視頻、儲存線上視頻到本地相簿的能力。
WVVideo.chooseVideo
該API只在Windvane Android 1.0.3.4以上版本有效。
拍攝視頻或從手機中選取視頻。
輸入參數
[
string] mode:拍照或是從相簿選擇,'camera'表示調用相機進行拍攝,'video'表示從手機中選取視頻,預設'both';[
boolean] compatible: 可選,present 小程式後調用相關操作需要設定為true。
回調參數
成功回調參數:
[
string] path:視頻的檔案路徑。[
string] fileSize:視頻的檔案大小。[
string] duration:視頻的時間長度。[
string] width:視頻寬度。[
string] height:視頻高度。
失敗回調參數:
[
string] msg:錯誤訊息。
監聽事件
WVVideo.Event.chooseVideoSuccess:選擇視頻成功
事件參數:
[
string] path:視頻的檔案路徑。[
string] fileSize:視頻的檔案大小。[
string] duration:視頻的時間長度。[
string] width:視頻寬度。[
string] height:視頻高度。
WVVideo.Event.chooseVideoFailed:選擇視頻失敗
事件參數:
[
string] msg:錯誤訊息。
document.addEventListener('WVVideo.Event.chooseVideoSuccess', function (e) {
alert('event chooseVideoSuccess: ' + JSON.stringify(e.param));
});
document.addEventListener('WVVideo.Event.chooseVideoFailed', function (e) {
alert('event chooseVideoSuccess: ' + JSON.stringify(e.param));
});
var params = {
mode: 'both'
};
window.WindVane.call('WVVideo', 'chooseVideo', params, function(e) {
alert('success: ' + JSON.stringify(e));
}, function(e) {
alert('failure: ' + JSON.stringify(e));
});WVVideo.saveVideoToPhotosAlbum
該API只在Windvane Android 1.0.3.4以上版本有效。
儲存線上視頻至本地相簿。
輸入參數
[
string] url:線上視頻的URL下載地址。注意:必須是可下載的URL地址,且目前支援HTTP和HTTPS協議的URL地址。
回調參數
成功回調參數:
無回調參數。
失敗回調參數:
[
string] msg:錯誤訊息。
監聽事件
WVVideo.Event.saveVideoSuccess:儲存線上視頻至本地相簿成功
事件參數:
無參數。
WVVideo.Event.saveVideoFailed:儲存線上視頻至本地相簿失敗
事件參數:
[
string] msg:錯誤訊息。
document.addEventListener('WVVideo.Event.saveVideoSuccess', function (e) {
alert('event saveVideoSuccess: ' + JSON.stringify(e.param));
});
document.addEventListener('WVVideo.Event.saveVideoFailed', function (e) {
alert('event saveVideoFailed: ' + JSON.stringify(e.param));
});
var params = {
url: 'http://xxxx'
};
window.WindVane.call('WVVideo', 'saveVideoToPhotosAlbum', params, function(e) {
alert('success: ' + JSON.stringify(e));
}, function(e) {
alert('failure: ' + JSON.stringify(e));
});