The WVVideo module provides JSAPIs for recording a video, selecting a video from the device album, or saving an online video to the local album in H5 apps and miniapps.
WVVideo.chooseVideo
This API is available only in WindVane for Android 1.0.3.4 or later.
Records a video using the camera or selects one from the device album.
Input parameters
[
string]mode: Video source. Valid values:'camera'(record a new video),'video'(select from the album),'both'(let the user choose). Default:'both'.[
boolean]compatible: Optional. Set totrueif the API is called after a miniapp is presented.
Callback parameters
On success, the callback receives an object with the following fields:
[
string]path: File path of the selected or recorded video.[
string]fileSize: File size of the video.[
string]duration: Duration of the video.[
string]width: Width of the video.[
string]height: Height of the video.
On failure, the callback receives an object with the following field:
[
string]msg: Error message describing why the operation failed.
Events
WVVideo.Event.chooseVideoSuccess
Event parameters:
[
string]path: File path of the selected or recorded video.[
string]fileSize: File size of the video.[
string]duration: Duration of the video.[
string]width: Width of the video.[
string]height: Height of the video.
WVVideo.Event.chooseVideoFailed
Event parameters:
[
string]msg: Error message describing why the operation failed.
document.addEventListener('WVVideo.Event.chooseVideoSuccess', function (e) {
alert('event chooseVideoSuccess: ' + JSON.stringify(e.param));
});
document.addEventListener('WVVideo.Event.chooseVideoFailed', function (e) {
alert('event chooseVideoFailed: ' + 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
This API is available only in WindVane for Android 1.0.3.4 or later.
Saves an online video to the local album.
Input parameters
[
string]url: Download URL of the online video. Must be a directly downloadable HTTP or HTTPS URL.
Callback parameters
On success, the callback receives no parameters.
None.
On failure, the callback receives an object with the following field:
[
string]msg: Error message describing why the operation failed.
Events
WVVideo.Event.saveVideoSuccess
Event parameters:
None.
WVVideo.Event.saveVideoFailed
Event parameters:
[
string]msg: Error message describing why the operation failed.
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));
});