uniapp拍摄和播放
文章描述:
uniapp调用摄像头拍摄视频然后加载到Video里面播放
template
<template>
<view>
<button @tap="videoClick"></button>
<video :src="src" :poster="thumb"></video>
</view>
</template>
script
var _self;
export default {
data() {
return {
src: '',
thumb:''
}
},
methods: {
videoClick: function () {
var self = this;
uni.chooseVideo({
count: 1,
sourceType: ['camera'],
success: function (res) {
self.src = res.tempFilePath;
self.thumb = res.thumbTempFilePath;
console.log(res.tempFilePath);
console.log(res.thumbTempFilePath);
}
});
}
}
}
style
button{
background-image: url(../../static/images/icon-camera.png);
background-size: cover;
width: 48upx;
height: 50upx;
margin-bottom: 20upx;
}
video{
margin: 0 auto;
display: block;
}
icon图标
发布时间:2021/09/27
发表评论