Video

更新时间:
复制 MD 格式

This topic describes the JavaScript APIs (JSAPIs) for the WVVideo class. You can use these APIs to create H5 applications or Mini Programs for cross-platform development. The WVVideo JSAPIs allow you to select a video from an album, record a video using the camera, and save an online video to a local album.

WVVideo.chooseVideo

Note

This API is available in Windvane for Android 1.0.3.4 or later.

Records a video or selects a video from your phone.

Input parameters

  • [string] mode: The method used to obtain the video. 'camera' specifies that a video is recorded using the camera. 'video' specifies that a video is selected from the phone.

Callback parameters

Success callback parameters:

  • [string] path: The file path of the video.

  • [string] fileSize: The file size of the video.

  • [string] duration: The duration of the video.

  • [string] width: The width of the video.

  • [string] height: The height of the video.

Failure callback parameters:

  • [string] msg: The error message.

Listeners

WVVideo.Event.chooseVideoSuccess: This event is triggered when a video is successfully selected.

Event parameters:

  • [string] path: The file path of the video.

  • [string] fileSize: The file size of the video.

  • [string] duration: The duration of the video.

  • [string] width: The width of the video.

  • [string] height: The height of the video.

WVVideo.Event.chooseVideoFailed: Failed to choose a video

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 chooseVideoFailed: ' + JSON.stringify(e.param));
});

var params = {
  mode: 'camera'
};
window.WindVane.call('WVVideo', 'chooseVideo', params, function(e) {
        alert('success: ' + JSON.stringify(e));
}, function(e) {
        alert('failure: ' + JSON.stringify(e));
});

WVVideo.saveVideoToPhotosAlbum

Note

This API is available in Windvane for Android 1.0.3.4 or later.

Saves an online video to a local photo album.

Input parameters

  • [string] url: The download URL of the online video. Note: The URL must be a downloadable link that uses the HTTP or HTTPS protocol.

Callback parameters

Success callback parameters:

  • None.

Failure callback parameters:

  • [string] msg: The error message.

Listener Events

WVVideo.Event.saveVideoSuccess: This event is triggered when the online video is successfully saved to the local album.

Event parameters:

  • None.

WVVideo.Event.saveVideoFailed: This event is triggered when the system fails to save the online video to the local album.

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));
});