1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
| var Constant = require('../../utils/constant.js');
| var app = getApp();
| import Request from "../../utils/api"
| /**
| * ifRotate:是否可旋转
| * ifFocusing:是否可调焦
| */
| const urls = [{
| name: '1号监控',
| src: 'http://hls01open.ys7.com/openlive/6d7b9734fad3402d9537ce5ae1ce3467.hd.m3u8',
| IsRotateAble: false,
| IsZoomble: false
| },
| {
| name: '2号监控',
| src: 'http://hls01open.ys7.com/openlive/61a4e139e958496692312c6f3fcf28b0.m3u8',
| IsRotateAble: true,
| IsZoomble: false
| },
| {
| name: '3号监控',
| src: 'http://hls01open.ys7.com/openlive/b7100af682fb42dd8c5230e9bbad3b1b.hd.m3u8',
| IsRotateAble: false,
| IsZoomble: false
| }
| ]
|
|
| Page({
| data: {
| list: {},
| moreVideo: [],
| fullScreen: false, // 操作是否显示
| currentCorpID:0,
| },
| onLoad(options) {
| this.videoContext = wx.createVideoContext('myVideo')
| console.log(options.id)
| var that = this;
| if (options.id == undefined) {
| wx.setNavigationBarTitle({
| title: '监控',
| })
| } else {
| wx.setNavigationBarTitle({
| title: options.Name + '监控',
| })
| }
| if (options.more == 'CA') {
| that.setData({
| moreVideo: urls
| })
| return;
| }
| that.setData({
| currentCorpID:options.corpID
| })
| that.onEquipment(options.id);
| },
| onShareAppMessage: function () {
| return Constant.Share;
| },
| /**播放 */
| bindPlay: function () {
| this.videoContext.play()
| },
| /**暂停 */
| bindPause: function () {
| this.videoContext.pause()
| },
| /**播放错误 */
| videoErrorCallback: function (e) {
| this.showModal("提示", "视频错误信息")
| console.log(e.detail.errMsg)
| },
| /**视频进入/退出全屏 */
| fullScreen(e) {
| if (e.detail.fullScreen) {
| this.setData({
| fullScreen: true
| })
| } else {
| this.setData({
| fullScreen: false
| })
| }
| },
|
|
|
|
|
|
| onEquipment(id) {
| console.log(id,90)
| if (id == undefined) {
| var id = 2;
| }
| var that = this;
| Request({
| url: Constant.BASE_SERVER_URL + "Product/Camera/Mobile/GetDetailByID@V1.0",
| header: {
| 'content-type': 'application/json'
| },
| method: 'GET',
| data: {
| CorpID : that.data.currentCorpID,
| ID: id
| },
| success: function (res) {
| console.log(res, '摄像头信息')
| id = id - 1; //减1获取下标
| var m_caremaList = res.data.Data;
| that.setData({
| list: m_caremaList
| })
| that.getVideoAddressSrc(m_caremaList.TokenInfo.ViewToken,m_caremaList.SeriesNO,m_caremaList.TokenInfo.ChannelNo)
| // console.log(that.data.list,"list")
| },
| fail: function (res) {
| console.log('失败')
| },
| })
| },
| //获取所有的视频列表的播放路径
| getVideoAddressSrc(token,deviceNo,channelNo){
| let that = this
| // console.log(token,deviceNo + ":" + channelNo,132)
| wx.request({
| url: Constant.YING_SHI_URL + "api/lapp/live/address/get",
| header: {
| 'content-type': 'application/x-www-form-urlencoded'
| },
| method: 'POST',
| data: {
| accessToken : token,
| source:deviceNo + ":" + channelNo
| },
| success: function (res) {
| console.log(res, '摄像头播放地址')
| let m_allVideoAddressInfo = res.data.data;
| var m_caremaList = that.data.list;
| m_caremaList.TokenInfo.LiveUrl = m_allVideoAddressInfo[0].hls
| that.setData({
| list: m_caremaList
| })
| console.log(that.data.list,"list")
| },
| fail: function (res) {
| console.log('失败')
| },
| })
| },
|
|
| fullScreenStart(e) {
| var that = this;
| var m_caremaList = that.data.list;
| var i = 1;
| var cmd = e.currentTarget.dataset.cmd;
| wx.request({
| url: Constant.YING_SHI_URL + "api/lapp/device/ptz/start",
| method: 'POST',
| header: {
| 'Content-Type': 'application/x-www-form-urlencoded'
| },
| data: {
| accessToken: m_caremaList.TokenInfo.ViewToken,
| deviceSerial: m_caremaList.SeriesNO,
| channelNo: 1,
| direction: cmd,
| speed: 1,
| },
| success: function (res) {
| // console.log(res, i, cmd, '成功fullScreenStart', m_caremaList.ViewToken, m_caremaList.SeriesNO)
| },
| fail: function (res) {
| console.log('失败')
| },
| })
| },
| fullScreenEnd(e) {
| var that = this;
| var m_caremaList = that.data.list;
| var i = 1;
| var cmd = e.currentTarget.dataset.cmd;
| wx.request({
| url: Constant.YING_SHI_URL + "api/lapp/device/ptz/stop",
| method: 'POST',
| header: {
| 'Content-Type': 'application/x-www-form-urlencoded'
| },
| data: {
| accessToken: m_caremaList.TokenInfo.ViewToken,
| deviceSerial: m_caremaList.SeriesNO,
| channelNo: 1,
| direction: cmd,
| speed: 1,
| },
| success: function (res) {
| // console.log(res, i, cmd,'成功fullScreenEnd')
| },
| fail: function (res) {
| console.log('失败')
| },
| })
|
| },
| showModal(title, body) {
| wx.showModal({
| title: title,
| content: body,
| success: function (res) {},
| fail: function (res) {}
| })
| },
|
| onBindtimeupdate(e) {
| var videoTime = e.detail
| this.setData({
| videoTime: {
| currentTime: videoTime.currentTime,
| duration: videoTime.duration
| }
| })
| },
|
|
| })
|
|