diff --git a/app.json b/app.json index e2d5679..8df6600 100644 --- a/app.json +++ b/app.json @@ -1,5 +1,6 @@ { "pages": [ + "pages/video/index", "pages/index/index/index", "pages/goods/categoryList/categoryList", "pages/cart/cart/cart", @@ -83,19 +84,7 @@ "pages/user/assistance/assistance_success", "pages/user/assistance/assistance" - ], - "subPackages": [ - { - "root": "packageA/", - "pages": [], - "plugins": { - "live-player-plugin": { - "version": "1.0.2", - "provider": "wx2b03c6e691cd7370" - } - } - } - ], + ], "permission": { "scope.userLocation": { "desc": "获取你的位置信息" diff --git a/pages/video/index.js b/pages/video/index.js new file mode 100644 index 0000000..aaab839 --- /dev/null +++ b/pages/video/index.js @@ -0,0 +1,52 @@ +function getRandomColor () { + let rgb = [] + for (let i = 0 ; i < 3; ++i){ + let color = Math.floor(Math.random() * 256).toString(16) + color = color.length == 1 ? '0' + color : color + rgb.push(color) + } + return '#' + rgb.join('') +} + +Page({ + onReady: function (res) { + this.videoContext = wx.createVideoContext('myVideo') + }, + inputValue: '', + data: { + src: '', + danmuList: [ + { + text: '第 1s 出现的弹幕', + color: '#ff0000', + time: 1 + }, + { + text: '第 3s 出现的弹幕', + color: '#ff00ff', + time: 3 + }] + }, + bindInputBlur: function(e) { + this.inputValue = e.detail.value + }, + bindButtonTap: function() { + var that = this + wx.chooseVideo({ + sourceType: ['album', 'camera'], + maxDuration: 60, + camera: ['front','back'], + success: function(res) { + that.setData({ + src: res.tempFilePath + }) + } + }) + }, + bindSendDanmu: function () { + this.videoContext.sendDanmu({ + text: this.inputValue, + color: getRandomColor() + }) + } +}) \ No newline at end of file diff --git a/pages/video/index.json b/pages/video/index.json new file mode 100644 index 0000000..78ba31c --- /dev/null +++ b/pages/video/index.json @@ -0,0 +1,4 @@ +{ + "navigationBarTitleText": "视频", + "enablePullDownRefresh": false +} \ No newline at end of file diff --git a/pages/video/index.wxml b/pages/video/index.wxml new file mode 100644 index 0000000..429dced --- /dev/null +++ b/pages/video/index.wxml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/pages/video/index.wxss b/pages/video/index.wxss new file mode 100644 index 0000000..21ca0bb --- /dev/null +++ b/pages/video/index.wxss @@ -0,0 +1,7 @@ +.page-body-button { + margin-bottom: 30rpx; +} + +video { + width: 100%; +} \ No newline at end of file