This topic describes the JavaScript APIs of WVVideo. You can refer to this topic when you create HTML5 apps or Miniapps. The JavaScript APIs of WVVideo provide the capabilities to select a video from the album or use a camera to shoot a video, and save an online video to the local album.
WVVideo.chooseVideo
This API is available only in WindVane Android 1.0.3.4 or later, WindVane iOS 2.1.4 or later.
Shoots a video or selects a video from the album.
Input parameters
[
string]mode: specifies to shoot a video or select a video from the album, 'camera' specifies to shoot a video, 'video' specifies to select a video from the album of the device. default is 'both'.[
boolean] compatible: optional, need to set true after presented the miniapp.
Callback parameters
Parameters for the success callback:
[
string]path: the path of the video file.[
string]fileSize: the size of the video file.[
string]duration: the duration of the video.[
string]width: the width of the video.[
string]height: the height of the video.
Parameters for the failure callback:
[
string]msg: the error message.
Event listening
WVVideo.Event.chooseVideoSuccess
Event parameters:
[
string]path: the path of the video file.[
string]fileSize: the size of the video file.[
string]duration: the duration of the video.[
string]width: the width of the video.[
string]height: the height of the video.
WVVideo.Event.chooseVideoFailed
Event parameters:
[
string]msg: the error message.
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
This API is available only in WindVane Android 1.0.3.4 or later, WindVane iOS 2.1.4 or later.
Saves an online video to the local album.
Input parameters
[
string]url: the download URL of the online video. Note: The video must be downloadable from the URL. The URL can be an HTTP or HTTPS URL.
Callback parameters
Parameters for the success callback:
No callback parameters exist.
Parameters for the failure callback:
[
string]msg: the error message.
Event listening
WVVideo.Event.saveVideoSuccess
Event parameters:
No parameters exist.
WVVideo.Event.saveVideoFailed
Event parameters:
[
string]msg: the error message.
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));
});