previewVideo
previewVideo là API dùng để preview view từ đường dẫn cục bộ ví dụ từ chooseVideo hoặc đường dẫn remote online
Tham số
| Thuộc tính | Kiểu dữ liệu | Bắt buộc | Mô tả |
|---|---|---|---|
| url | string | ✓ | Đường dẫn cục bộ hoặc online |
| success | Function | Callback function khi preview video thành công | |
| fail | Function | Callback function khi preview video bất thành. | |
| complete | Function | Callback function khi gọi API hoàn tất bất kể có preview video hay không. |
Callback function payload
Không có
Ví dụ
import apis from '@v-miniapp/apis'
function onChooseVideo() {
apis.chooseVideo({
camera: 'front',
maxDuration: 15,
includeThumbnail: true,
success: res => {
apis.alert({ content: JSON.stringify(res) })
// Automatically preview images after selection
if (res.filePaths[0].length > 0) {
apis.previewVideo({
url: res.filePaths[0],
})
}
},
fail: e => {
apis.alert({ content: JSON.stringify(e) })
console.log(e)
},
})
}