123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- Component({
- behaviors: [require('../common/share-behavior').default],
- properties: {
- captureState: {
- type: Number,
- value: 0,
- observer: function (newVal, oldVal) {
- if (newVal !== oldVal) {
- if (newVal === 1) {
- this.capture();
- }
- }
- },
- },
- recordState: {
- type: Number,
- value: 0,
- observer: function (newVal, oldVal) {
- if (newVal !== oldVal) {
- if (newVal === 0) {
- this.recordEnd();
- } else {
- this.recordStart();
- }
- }
- }
- },
- captureQuality: {
- type: Number,
- value: 0.8,
- },
- captureType: {
- type: String,
- value: 'jpg',
- },
- recordFPS: {
- type: Number,
- value: 30,
- },
- recordWidth: {
- type: Number,
- value: undefined,
- },
- recordHeight: {
- type: Number,
- value: undefined,
- },
- recordBPS: {
- type: Number,
- value: 1000,
- },
- },
- data: {
- loaded: false
- },
- lifetimes: {},
- methods: {
- handleReady({detail}) {
- const scene = this.scene = detail.value;
- const appHide = () => this.scene.share.recordPause();
- const appShow = () => this.scene.share.recordResume();
- wx.onAppHide(appHide);
- wx.onAppShow(appShow);
- wx.offAppHide(appHide);
- wx.offAppShow(appShow);
-
- this.triggerEvent('sceneReady', {width: scene.width, height: scene.height});
- },
- capture() {
- this.scene.share.captureToFriends({
- fileType: this.data.captureType,
- quality: this.data.captureQuality
- });
- },
- recordStart() {
- console.log('recordStart')
- wx.updateShareMenu({
- withShareTicket: true,
- success () { }
- })
- this.scene.share.recordStart({
- fps: this.data.recordFPS,
- videoBitsPerSecond: this.data.recordBPS,
- width: this.data.recordWidth,
- height: this.data.recordHeight
- });
- },
- recordEnd() {
- console.log('recordEnd')
-
-
- //
- const tempFilePath = this.scene.share.recordFinishToTempFile({
- fps: this.data.recordFPS,
- videoBitsPerSecond: this.data.recordBPS,
- width: this.data.recordWidth,
- height: this.data.recordHeight
- });
- wx.shareVideoMessage({
- videoPath: tempFilePath,
- });
- }
- }
- })
|