这里有新鲜出炉的微信小程序入门,程序狗速度看过来!
微信小程序(weixinxiaochengxu),简称小程序,缩写 XCX,英文名 mini program,是一种不需要下载安装即可使用的应用,它实现了应用 "触手可及" 的梦想,用户扫一扫或搜一下即可打开应用。
这篇文章主要介绍了 微信小程序 Video API 实例详解, 需要的朋友可以参考下
电脑端不能测试拍摄功能只能测试选择视频功能,好像只支持 mp4 格式,值得注意的是成功之后返回的临时文件路径是个列表 tempFilePaths 而不是 tempFilePath 文档写的有点问题。
主要属性:
wx.chooseVideo(object)
成功之后返回参数
wxml
- <button type="primary" bindtap="listenerBtnOpenVideo">
- 打开视频
- </button>
- <!--默认视频组件是隐藏的-->
- <video src="{{videoSource}}" hidden="{{videoHidden}}" style="width: 100%; height: 100%"
- />
js
- Page({
- data: {
- // text:"这是一个页面"
- videoSource: '',
- videoHidden: true
- },
- listenerBtnOpenVideo: function() {
- var that = this;
- wx.chooseVideo({
- //相机和相册
- sourceType: ['album', 'camera'],
- //录制视频最大时长
- maxDuration: 60,
- //摄像头
- camera: ['front', 'back'],
- //这里返回的是tempFilePaths并不是tempFilePath
- success: function(res) {
- console.log(res.tempFilePaths[0]) that.setData({
- videoSource: res.tempFilePaths[0],
- videoHidden: false
- })
- },
- fail: function(e) {
- console.log(e)
- }
- })
- },
- onLoad: function(options) {
- // 页面初始化 options为页面跳转所带来的参数
- },
- onReady: function() {
- // 页面渲染完成
- },
- onShow: function() {
- // 页面显示
- },
- onHide: function() {
- // 页面隐藏
- },
- onUnload: function() {
- // 页面关闭
- }
- })
来源: http://www.phperz.com/article/17/0723/331457.html