tiny-vue/examples/sites/demos/mobile-first/app/file-upload/multi-media-native.vue

66 lines
1.8 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<tiny-file-upload
:action="action"
list-type="picture-card"
source-type="audio/video/picture"
:file-list="fileList"
:hwh5="hwh5"
@trigger-click="handleTriggerClick"
@play="handlePlay"
>
</tiny-file-upload>
</template>
<script>
import { FileUpload } from '@opentiny/vue'
export default {
components: {
TinyFileUpload: FileUpload
},
data() {
return {
hwh5: {
HWH5: () => window.HWH5 || {}
},
action: 'http://localhost:3000/api/upload',
fileList: [
{
name: 'video-test.mp4',
url: 'http://hicdev.huawei.com/mirrors/academy/Intro%20to%20Vue.js/1%29%20The%20Vue%20Instance.mp4'
},
{
name: 'audio-test.3gp',
type: 'audio',
url: 'https://hicdev.huawei.com/mirrors/resource/audio-test.3gp'
}
]
}
},
methods: {
handleTriggerClick($event, sourceType, type) {
/**
* $event事件对象
* sourceType表示选取资源类型picture、video、audio图片、视频、音频
* sourceType为picture时type: 1 从相册选择; type: 2 拍摄
* sourceType为video时type: 1 从相册选择; type: 3 录像
* sourceType为audio时type类型包括start、pause、continue、end、cancel
* type: start 开始录音;
* type: pause 中止录音;
* type: continue 继续录音;
* type: end 结束录音;
* type: cancel 取消录音
*/
console.log('handleTriggerClick', $event, sourceType, type)
},
handlePlay(file, sourceType) {
/**
* file为文件对象
* sourceType表示选取资源类型video、audio视频、音频
*/
console.log('handlePlay', file, sourceType)
}
}
}
</script>