devicePlayer.vue 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011
  1. <template>
  2. <div id="devicePlayer" v-loading="isLoging">
  3. <el-dialog title="视频播放" top="0" :close-on-click-modal="false" :visible.sync="showVideoDialog" @close="close()">
  4. <!-- <LivePlayer v-if="showVideoDialog" ref="videoPlayer" :videoUrl="videoUrl" :error="videoError" :message="videoError" :hasaudio="hasaudio" fluent autoplay live></LivePlayer> -->
  5. <div style="width: 100%; height: 100%">
  6. <el-tabs type="card" :stretch="true" v-model="activePlayer" @tab-click="changePlayer" v-if="Object.keys(this.player).length > 1">
  7. <el-tab-pane label="Jessibuca" name="jessibuca">
  8. <jessibucaPlayer v-if="activePlayer === 'jessibuca'" ref="jessibuca" :visible.sync="showVideoDialog" :videoUrl="videoUrl" :error="videoError" :message="videoError" height="100px" :hasAudio="hasAudio" fluent autoplay live ></jessibucaPlayer>
  9. </el-tab-pane>
  10. <el-tab-pane label="WebRTC" name="webRTC">
  11. <rtc-player v-if="activePlayer === 'webRTC'" ref="webRTC" :visible.sync="showVideoDialog" :videoUrl="videoUrl" :error="videoError" :message="videoError" height="100px" :hasAudio="hasAudio" fluent autoplay live ></rtc-player>
  12. </el-tab-pane>
  13. <el-tab-pane label="h265web">h265web敬请期待</el-tab-pane>
  14. <el-tab-pane label="wsPlayer">wsPlayer 敬请期待</el-tab-pane>
  15. </el-tabs>
  16. <jessibucaPlayer v-if="Object.keys(this.player).length == 1 && this.player.jessibuca" ref="jessibuca" :visible.sync="showVideoDialog" :videoUrl="videoUrl" :error="videoError" :message="videoError" height="100px" :hasAudio="hasAudio" fluent autoplay live ></jessibucaPlayer>
  17. <rtc-player v-if="Object.keys(this.player).length == 1 && this.player.webRTC" ref="jessibuca" :visible.sync="showVideoDialog" :videoUrl="videoUrl" :error="videoError" :message="videoError" height="100px" :hasAudio="hasAudio" fluent autoplay live ></rtc-player>
  18. </div>
  19. <div id="shared" style="text-align: right; margin-top: 1rem;">
  20. <el-tabs v-model="tabActiveName" @tab-click="tabHandleClick" >
  21. <el-tab-pane label="实时视频" name="media">
  22. <div style="margin-bottom: 0.5rem;">
  23. <!-- <el-button type="primary" size="small" @click="playRecord(true, '')">播放</el-button>-->
  24. <!-- <el-button type="primary" size="small" @click="startRecord()">录制</el-button>-->
  25. <!-- <el-button type="primary" size="small" @click="stopRecord()">停止录制</el-button>-->
  26. </div>
  27. <div style="display: flex; margin-bottom: 0.5rem; height: 2.5rem;">
  28. <span style="width: 5rem; line-height: 2.5rem; text-align: right;">播放地址:</span>
  29. <el-input v-model="getPlayerShared.sharedUrl" :disabled="true" >
  30. <template slot="append">
  31. <i class="cpoy-btn el-icon-document-copy" title="点击拷贝" v-clipboard="getPlayerShared.sharedUrl" @success="$message({type:'success', message:'成功拷贝到粘贴板'})"></i>
  32. </template>
  33. </el-input>
  34. </div>
  35. <div style="display: flex; margin-bottom: 0.5rem; height: 2.5rem;">
  36. <span style="width: 5rem; line-height: 2.5rem; text-align: right;">iframe:</span>
  37. <el-input v-model="getPlayerShared.sharedIframe" :disabled="true" >
  38. <template slot="append">
  39. <i class="cpoy-btn el-icon-document-copy" title="点击拷贝" v-clipboard="getPlayerShared.sharedIframe" @success="$message({type:'success', message:'成功拷贝到粘贴板'})"></i>
  40. </template>
  41. </el-input>
  42. </div>
  43. <div style="display: flex; margin-bottom: 0.5rem; height: 2.5rem;">
  44. <span style="width: 5rem; line-height: 2.5rem; text-align: right;">资源地址:</span>
  45. <el-input v-model="getPlayerShared.sharedRtmp" :disabled="true" >
  46. <el-button slot="append" icon="el-icon-document-copy" title="点击拷贝" v-clipboard="getPlayerShared.sharedRtmp" @success="$message({type:'success', message:'成功拷贝到粘贴板'})"></el-button>
  47. <el-dropdown slot="prepend" v-if="streamInfo" trigger="click" @command="copyUrl">
  48. <el-button >
  49. 更多地址<i class="el-icon-arrow-down el-icon--right"></i>
  50. </el-button>
  51. <el-dropdown-menu slot="dropdown" >
  52. <el-dropdown-item :command="streamInfo.flv">
  53. <el-tag >FLV:</el-tag>
  54. <span>{{ streamInfo.flv }}</span>
  55. </el-dropdown-item>
  56. <el-dropdown-item :command="streamInfo.https_flv">
  57. <el-tag >FLV(https):</el-tag>
  58. <span>{{ streamInfo.https_flv }}</span>
  59. </el-dropdown-item>
  60. <el-dropdown-item :command="streamInfo.ws_flv">
  61. <el-tag >FLV(ws):</el-tag>
  62. <span >{{ streamInfo.ws_flv }}</span>
  63. </el-dropdown-item>
  64. <el-dropdown-item :command="streamInfo.wss_flv">
  65. <el-tag >FLV(wss):</el-tag>
  66. <span>{{ streamInfo.wss_flv }}</span>
  67. </el-dropdown-item>
  68. <el-dropdown-item :command="streamInfo.fmp4">
  69. <el-tag >FMP4:</el-tag>
  70. <span>{{ streamInfo.fmp4 }}</span>
  71. </el-dropdown-item>
  72. <el-dropdown-item :command="streamInfo.https_fmp4">
  73. <el-tag >FMP4(https):</el-tag>
  74. <span>{{ streamInfo.https_fmp4 }}</span>
  75. </el-dropdown-item>
  76. <el-dropdown-item :command="streamInfo.ws_fmp4">
  77. <el-tag >FMP4(ws):</el-tag>
  78. <span>{{ streamInfo.ws_fmp4 }}</span>
  79. </el-dropdown-item>
  80. <el-dropdown-item :command="streamInfo.wss_fmp4">
  81. <el-tag >FMP4(wss):</el-tag>
  82. <span>{{ streamInfo.wss_fmp4 }}</span>
  83. </el-dropdown-item>
  84. <el-dropdown-item :command="streamInfo.hls">
  85. <el-tag>HLS:</el-tag>
  86. <span>{{ streamInfo.hls }}</span>
  87. </el-dropdown-item>
  88. <el-dropdown-item :command="streamInfo.https_hls">
  89. <el-tag >HLS(https):</el-tag>
  90. <span>{{ streamInfo.https_hls }}</span>
  91. </el-dropdown-item>
  92. <el-dropdown-item :command="streamInfo.ws_hls">
  93. <el-tag >HLS(ws):</el-tag>
  94. <span>{{ streamInfo.ws_hls }}</span>
  95. </el-dropdown-item>
  96. <el-dropdown-item :command="streamInfo.wss_hls">
  97. <el-tag >HLS(wss):</el-tag>
  98. <span>{{ streamInfo.wss_hls }}</span>
  99. </el-dropdown-item>
  100. <el-dropdown-item :command="streamInfo.ts">
  101. <el-tag>TS:</el-tag>
  102. <span>{{ streamInfo.ts }}</span>
  103. </el-dropdown-item>
  104. <el-dropdown-item :command="streamInfo.https_ts">
  105. <el-tag>TS(https):</el-tag>
  106. <span>{{ streamInfo.https_ts }}</span>
  107. </el-dropdown-item>
  108. <el-dropdown-item :command="streamInfo.ws_ts">
  109. <el-tag>TS(ws):</el-tag>
  110. <span>{{ streamInfo.ws_ts }}</span>
  111. </el-dropdown-item>
  112. <el-dropdown-item :command="streamInfo.wss_ts">
  113. <el-tag>TS(wss):</el-tag>
  114. <span>{{ streamInfo.wss_ts }}</span>
  115. </el-dropdown-item>
  116. <el-dropdown-item :command="streamInfo.rtc">
  117. <el-tag >RTC:</el-tag>
  118. <span>{{ streamInfo.rtc }}</span>
  119. </el-dropdown-item>
  120. <el-dropdown-item :command="streamInfo.rtmp">
  121. <el-tag >RTMP:</el-tag>
  122. <span>{{ streamInfo.rtmp }}</span>
  123. </el-dropdown-item>
  124. <el-dropdown-item :command="streamInfo.rtmps">
  125. <el-tag >RTMPS:</el-tag>
  126. <span>{{ streamInfo.rtmps }}</span>
  127. </el-dropdown-item>
  128. <el-dropdown-item :command="streamInfo.rtsp">
  129. <el-tag >RTSP:</el-tag>
  130. <span>{{ streamInfo.rtsp }}</span>
  131. </el-dropdown-item>
  132. <el-dropdown-item :command="streamInfo.rtsps">
  133. <el-tag >RTSPS:</el-tag>
  134. <span>{{ streamInfo.rtsps }}</span>
  135. </el-dropdown-item>
  136. </el-dropdown-menu>
  137. </el-dropdown>
  138. </el-input>
  139. </div>
  140. </el-tab-pane>
  141. <!--{"code":0,"data":{"paths":["22-29-30.mp4"],"rootPath":"/home/kkkkk/Documents/ZLMediaKit/release/linux/Debug/www/record/hls/kkkkk/2020-05-11/"}}-->
  142. <el-tab-pane label="录像查询" name="record" v-if="showRrecord">
  143. <div style="width: 100%;">
  144. <div style="width: 100%; text-align: left">
  145. <span>录像控制</span>
  146. <el-button-group style="margin-left: 1rem;">
  147. <el-button size="mini" class="iconfont icon-zanting" title="开始" @click="gbPause()"></el-button>
  148. <el-button size="mini" class="iconfont icon-kaishi" title="暂停" @click="gbPlay()"></el-button>
  149. <el-dropdown size="mini" title="播放倍速" style="margin-left: 1px;" @command="gbScale">
  150. <el-button size="mini">
  151. 倍速 <i class="el-icon-arrow-down el-icon--right"></i>
  152. </el-button>
  153. <el-dropdown-menu slot="dropdown">
  154. <el-dropdown-item command="0.25">0.25倍速</el-dropdown-item>
  155. <el-dropdown-item command="0.5">0.5倍速</el-dropdown-item>
  156. <el-dropdown-item command="1.0">1倍速</el-dropdown-item>
  157. <el-dropdown-item command="2.0">2倍速</el-dropdown-item>
  158. <el-dropdown-item command="4.0">4倍速</el-dropdown-item>
  159. </el-dropdown-menu>
  160. </el-dropdown>
  161. </el-button-group>
  162. <el-date-picker style="float: right;" size="mini" v-model="videoHistory.date" type="date" value-format="yyyy-MM-dd" placeholder="日期" @change="queryRecords()"></el-date-picker>
  163. </div>
  164. <div style="width: 100%; text-align: left">
  165. <span class="demonstration" style="padding: 12px 36px 12px 0;float: left;">{{showTimeText}}</span>
  166. <el-slider style="width: 80%; float:left;" v-model="sliderTime" @change="gbSeek" :show-tooltip="false"></el-slider>
  167. </div>
  168. </div>
  169. <el-table :data="videoHistory.searchHistoryResult" height="150" v-loading="recordsLoading">
  170. <el-table-column label="名称" prop="name"></el-table-column>
  171. <el-table-column label="文件" prop="filePath"></el-table-column>
  172. <el-table-column label="开始时间" prop="startTime" :formatter="timeFormatter"></el-table-column>
  173. <el-table-column label="结束时间" prop="endTime" :formatter="timeFormatter"></el-table-column>
  174. <el-table-column label="操作">
  175. <template slot-scope="scope">
  176. <el-button-group>
  177. <el-button icon="el-icon-video-play" size="mini" @click="playRecord(scope.row)">播放</el-button>
  178. <el-button icon="el-icon-download" size="mini" @click="downloadRecord(scope.row)">下载</el-button>
  179. </el-button-group>
  180. </template>
  181. </el-table-column>
  182. </el-table>
  183. </el-tab-pane>
  184. <!--遥控界面-->
  185. <el-tab-pane label="云台控制" name="control" v-if="showPtz">
  186. <div style="display: flex; justify-content: left;">
  187. <div class="control-wrapper">
  188. <div class="control-btn control-top" @mousedown="ptzCamera('up')" @mouseup="ptzCamera('stop')">
  189. <i class="el-icon-caret-top"></i>
  190. <div class="control-inner-btn control-inner"></div>
  191. </div>
  192. <div class="control-btn control-left" @mousedown="ptzCamera('left')" @mouseup="ptzCamera('stop')">
  193. <i class="el-icon-caret-left"></i>
  194. <div class="control-inner-btn control-inner"></div>
  195. </div>
  196. <div class="control-btn control-bottom" @mousedown="ptzCamera('down')" @mouseup="ptzCamera('stop')">
  197. <i class="el-icon-caret-bottom"></i>
  198. <div class="control-inner-btn control-inner"></div>
  199. </div>
  200. <div class="control-btn control-right" @mousedown="ptzCamera('right')" @mouseup="ptzCamera('stop')">
  201. <i class="el-icon-caret-right"></i>
  202. <div class="control-inner-btn control-inner"></div>
  203. </div>
  204. <div class="control-round">
  205. <div class="control-round-inner"><i class="fa fa-pause-circle"></i></div>
  206. </div>
  207. <div style="position: absolute; left: 7.25rem; top: 1.25rem" @mousedown="ptzCamera('zoomin')" @mouseup="ptzCamera('stop')"><i class="el-icon-zoom-in control-zoom-btn" style="font-size: 1.875rem;"></i></div>
  208. <div style="position: absolute; left: 7.25rem; top: 3.25rem; font-size: 1.875rem;" @mousedown="ptzCamera('zoomout')" @mouseup="ptzCamera('stop')"><i class="el-icon-zoom-out control-zoom-btn"></i></div>
  209. <div class="contro-speed" style="position: absolute; left: 4px; top: 7rem; width: 9rem;">
  210. <el-slider v-model="controSpeed" :max="255"></el-slider>
  211. </div>
  212. </div>
  213. <div class="control-panel">
  214. <el-button-group>
  215. <el-tag style="position :absolute; left: 0rem; top: 0rem; width: 5rem; text-align: center" size="medium">预置位编号</el-tag>
  216. <el-input-number style="position: absolute; left: 5rem; top: 0rem; width: 6rem" size="mini" v-model="presetPos" controls-position="right" :precision="0" :step="1" :min="1" :max="255"></el-input-number>
  217. <el-button style="position: absolute; left: 11rem; top: 0rem; width: 5rem" size="mini" icon="el-icon-add-location" @click="presetPosition(129, presetPos)">设置</el-button>
  218. <el-button style="position: absolute; left: 27rem; top: 0rem; width: 5rem" size="mini" type="primary" icon="el-icon-place" @click="presetPosition(130, presetPos)">调用</el-button>
  219. <el-button style="position: absolute; left: 16rem; top: 0rem; width: 5rem" size="mini" icon="el-icon-delete-location" @click="presetPosition(131, presetPos)">删除</el-button>
  220. <el-tag style="position :absolute; left: 0rem; top: 2.5rem; width: 5rem; text-align: center" size="medium">巡航速度</el-tag>
  221. <el-input-number style="position: absolute; left: 5rem; top: 2.5rem; width: 6rem" size="mini" v-model="cruisingSpeed" controls-position="right" :precision="0" :min="1" :max="4095"></el-input-number>
  222. <el-button style="position: absolute; left: 11rem; top: 2.5rem; width: 5rem" size="mini" icon="el-icon-loading" @click="setSpeedOrTime(134, cruisingGroup, cruisingSpeed)">设置</el-button>
  223. <el-tag style="position :absolute; left: 16rem; top: 2.5rem; width: 5rem; text-align: center" size="medium">停留时间</el-tag>
  224. <el-input-number style="position: absolute; left: 21rem; top: 2.5rem; width: 6rem" size="mini" v-model="cruisingTime" controls-position="right" :precision="0" :min="1" :max="4095"></el-input-number>
  225. <el-button style="position: absolute; left: 27rem; top: 2.5rem; width: 5rem" size="mini" icon="el-icon-timer" @click="setSpeedOrTime(135, cruisingGroup, cruisingTime)">设置</el-button>
  226. <el-tag style="position :absolute; left: 0rem; top: 4.5rem; width: 5rem; text-align: center" size="medium">巡航组编号</el-tag>
  227. <el-input-number style="position: absolute; left: 5rem; top: 4.5rem; width: 6rem" size="mini" v-model="cruisingGroup" controls-position="right" :precision="0" :min="0" :max="255"></el-input-number>
  228. <el-button style="position: absolute; left: 11rem; top: 4.5rem; width: 5rem" size="mini" icon="el-icon-add-location" @click="setCommand(132, cruisingGroup, presetPos)">添加点</el-button>
  229. <el-button style="position: absolute; left: 16rem; top: 4.5rem; width: 5rem" size="mini" icon="el-icon-delete-location" @click="setCommand(133, cruisingGroup, presetPos)">删除点</el-button>
  230. <el-button style="position: absolute; left: 21rem; top: 4.5rem; width: 5rem" size="mini" icon="el-icon-delete" @click="setCommand(133, cruisingGroup, 0)">删除组</el-button>
  231. <el-button style="position: absolute; left: 27rem; top: 5rem; width: 5rem" size="mini" type="primary" icon="el-icon-video-camera-solid" @click="setCommand(136, cruisingGroup, 0)">巡航</el-button>
  232. <el-tag style="position :absolute; left: 0rem; top: 7rem; width: 5rem; text-align: center" size="medium">扫描速度</el-tag>
  233. <el-input-number style="position: absolute; left: 5rem; top: 7rem; width: 6rem" size="mini" v-model="scanSpeed" controls-position="right" :precision="0" :min="1" :max="4095"></el-input-number>
  234. <el-button style="position: absolute; left: 11rem; top: 7rem; width: 5rem" size="mini" icon="el-icon-loading" @click="setSpeedOrTime(138, scanGroup, scanSpeed)">设置</el-button>
  235. <el-tag style="position :absolute; left: 0rem; top: 9rem; width: 5rem; text-align: center" size="medium">扫描组编号</el-tag>
  236. <el-input-number style="position: absolute; left: 5rem; top: 9rem; width: 6rem" size="mini" v-model="scanGroup" controls-position="right" :precision="0" :step="1" :min="0" :max="255"></el-input-number>
  237. <el-button style="position: absolute; left: 11rem; top: 9rem; width: 5rem" size="mini" icon="el-icon-d-arrow-left" @click="setCommand(137, scanGroup, 1)">左边界</el-button>
  238. <el-button style="position: absolute; left: 16rem; top: 9rem; width: 5rem" size="mini" icon="el-icon-d-arrow-right" @click="setCommand(137, scanGroup, 2)">右边界</el-button>
  239. <el-button style="position: absolute; left: 27rem; top: 7rem; width: 5rem" size="mini" type="primary" icon="el-icon-video-camera-solid" @click="setCommand(137, scanGroup, 0)">扫描</el-button>
  240. <el-button style="position: absolute; left: 27rem; top: 9rem; width: 5rem" size="mini" type="danger" icon="el-icon-switch-button" @click="ptzCamera('stop')">停止</el-button>
  241. </el-button-group>
  242. </div>
  243. </div>
  244. </el-tab-pane>
  245. <el-tab-pane label="编码信息" name="codec" v-loading="tracksLoading">
  246. <p>
  247. 无法播放或者没有声音?&nbsp&nbsp&nbsp试一试&nbsp
  248. <el-button size="mini" type="primary" v-if="!coverPlaying" @click="coverPlay">转码播放</el-button>
  249. <el-button size="mini" type="danger" v-if="coverPlaying" @click="convertStopClick">停止转码</el-button>
  250. </p>
  251. <div class="trank" >
  252. <p v-if="tracksNotLoaded" style="text-align: center;padding-top: 3rem;">暂无数据</p>
  253. <div v-for="(item, index) in tracks" style="width: 50%; float: left" loading>
  254. <span >流 {{index}}</span>
  255. <div class="trankInfo" v-if="item.codec_type == 0">
  256. <p>格式: {{item.codec_id_name}}</p>
  257. <p>类型: 视频</p>
  258. <p>分辨率: {{item.width}} x {{item.height}}</p>
  259. <p>帧率: {{item.fps}}</p>
  260. </div>
  261. <div class="trankInfo" v-if="item.codec_type == 1">
  262. <p>格式: {{item.codec_id_name}}</p>
  263. <p>类型: 音频</p>
  264. <p>采样位数: {{item.sample_bit}}</p>
  265. <p>采样率: {{item.sample_rate}}</p>
  266. </div>
  267. </div>
  268. </div>
  269. </el-tab-pane>
  270. </el-tabs>
  271. </div>
  272. </el-dialog>
  273. <recordDownload ref="recordDownload"></recordDownload>
  274. </div>
  275. </template>
  276. <script>
  277. import rtcPlayer from '../dialog/rtcPlayer.vue'
  278. // import LivePlayer from '@liveqing/liveplayer'
  279. // import player from '../dialog/easyPlayer.vue'
  280. import jessibucaPlayer from '../common/jessibuca.vue'
  281. import recordDownload from '../dialog/recordDownload.vue'
  282. export default {
  283. name: 'devicePlayer',
  284. props: {},
  285. components: {
  286. jessibucaPlayer, rtcPlayer, recordDownload,
  287. },
  288. computed: {
  289. getPlayerShared: function () {
  290. return {
  291. sharedUrl: window.location.origin + '/#/play/wasm/' + encodeURIComponent(this.videoUrl),
  292. sharedIframe: '<iframe src="' + window.location.origin + '/#/play/wasm/' + encodeURIComponent(this.videoUrl) + '"></iframe>',
  293. sharedRtmp: this.videoUrl
  294. };
  295. }
  296. },
  297. created() {
  298. console.log(this.player)
  299. if (Object.keys(this.player).length === 1) {
  300. this.activePlayer = Object.keys(this.player)[0]
  301. }
  302. },
  303. data() {
  304. return {
  305. video: 'http://lndxyj.iqilu.com/public/upload/2019/10/14/8c001ea0c09cdc59a57829dabc8010fa.mp4',
  306. videoUrl: '',
  307. activePlayer: "jessibuca",
  308. // 如何你只是用一种播放器,直接注释掉不用的部分即可
  309. player: {
  310. jessibuca : ["ws_flv", "wss_flv"],
  311. webRTC: ["rtc", "rtc"],
  312. },
  313. videoHistory: {
  314. date: '',
  315. searchHistoryResult: [] //媒体流历史记录搜索结果
  316. },
  317. showVideoDialog: false,
  318. streamId: '',
  319. app : '',
  320. mediaServerId : '',
  321. convertKey: '',
  322. deviceId: '',
  323. channelId: '',
  324. tabActiveName: 'media',
  325. hasAudio: false,
  326. loadingRecords: false,
  327. recordsLoading: false,
  328. isLoging: false,
  329. controSpeed: 30,
  330. timeVal: 0,
  331. timeMin: 0,
  332. timeMax: 1440,
  333. presetPos: 1,
  334. cruisingSpeed: 100,
  335. cruisingTime: 5,
  336. cruisingGroup: 0,
  337. scanSpeed: 100,
  338. scanGroup: 0,
  339. tracks: [],
  340. coverPlaying:false,
  341. tracksLoading: false,
  342. recordPlay: "",
  343. showPtz: true,
  344. showRrecord: true,
  345. tracksNotLoaded: false,
  346. sliderTime: 0,
  347. seekTime: 0,
  348. recordStartTime: 0,
  349. showTimeText: "00:00:00",
  350. streamInfo: null,
  351. };
  352. },
  353. methods: {
  354. tabHandleClick: function(tab, event) {
  355. console.log(tab)
  356. var that = this;
  357. that.tracks = [];
  358. that.tracksLoading = true;
  359. that.tracksNotLoaded = false;
  360. if (tab.name === "codec") {
  361. this.$axios({
  362. method: 'get',
  363. url: '/zlm/' +this.mediaServerId+ '/index/api/getMediaInfo?vhost=__defaultVhost__&schema=rtsp&app='+ this.app +'&stream='+ this.streamId
  364. }).then(function (res) {
  365. that.tracksLoading = false;
  366. if (res.data.code == 0 && res.data.tracks) {
  367. that.tracks = res.data.tracks;
  368. }else{
  369. that.tracksNotLoaded = true;
  370. that.$message({
  371. showClose: true,
  372. message: '获取编码信息失败,',
  373. type: 'warning'
  374. });
  375. }
  376. }).catch(function (e) {});
  377. }
  378. },
  379. changePlayer: function (tab) {
  380. console.log(this.player[tab.name][0])
  381. this.activePlayer = tab.name;
  382. this.videoUrl = this.streamInfo[this.player[tab.name][0]]
  383. console.log(this.videoUrl)
  384. },
  385. openDialog: function (tab, deviceId, channelId, param) {
  386. if (this.showVideoDialog) {
  387. return;
  388. }
  389. this.tabActiveName = tab;
  390. this.channelId = channelId;
  391. this.deviceId = deviceId;
  392. this.streamId = "";
  393. this.mediaServerId = "";
  394. this.app = "";
  395. this.videoUrl = ""
  396. if (!!this.$refs[this.activePlayer]) {
  397. this.$refs[this.activePlayer].pause();
  398. }
  399. switch (tab) {
  400. case "media":
  401. this.play(param.streamInfo, param.hasAudio)
  402. break;
  403. case "record":
  404. this.showVideoDialog = true;
  405. this.videoHistory.date = param.date;
  406. this.queryRecords()
  407. break;
  408. case "streamPlay":
  409. this.tabActiveName = "media";
  410. this.showRrecord = false;
  411. this.showPtz = false;
  412. this.play(param.streamInfo, param.hasAudio)
  413. break;
  414. case "control":
  415. break;
  416. }
  417. },
  418. timeAxisSelTime: function (val) {
  419. console.log(val)
  420. },
  421. play: function (streamInfo, hasAudio) {
  422. this.streamInfo = streamInfo;
  423. this.hasAudio = hasAudio;
  424. this.isLoging = false;
  425. // this.videoUrl = streamInfo.rtc;
  426. this.videoUrl = this.getUrlByStreamInfo();
  427. this.streamId = streamInfo.stream;
  428. this.app = streamInfo.app;
  429. this.mediaServerId = streamInfo.mediaServerId;
  430. this.playFromStreamInfo(false, streamInfo)
  431. },
  432. getUrlByStreamInfo(){
  433. console.log(this.streamInfo)
  434. if (location.protocol === "https:") {
  435. this.videoUrl = this.streamInfo[this.player[this.activePlayer][1]]
  436. }else {
  437. this.videoUrl = this.streamInfo[this.player[this.activePlayer][0]]
  438. }
  439. return this.videoUrl;
  440. },
  441. coverPlay: function () {
  442. var that = this;
  443. this.coverPlaying = true;
  444. this.$refs[this.activePlayer].pause()
  445. that.$axios({
  446. method: 'post',
  447. url: '/api/play/convert/' + that.streamId
  448. }).then(function (res) {
  449. if (res.data.code === 0) {
  450. that.convertKey = res.data.key;
  451. setTimeout(()=>{
  452. that.isLoging = false;
  453. that.playFromStreamInfo(false, res.data.data);
  454. }, 2000)
  455. } else {
  456. that.isLoging = false;
  457. that.coverPlaying = false;
  458. that.$message({
  459. showClose: true,
  460. message: '转码失败',
  461. type: 'error'
  462. });
  463. }
  464. }).catch(function (e) {
  465. console.log(e)
  466. that.coverPlaying = false;
  467. that.$message({
  468. showClose: true,
  469. message: '播放错误',
  470. type: 'error'
  471. });
  472. });
  473. },
  474. convertStopClick: function() {
  475. this.convertStop(()=>{
  476. this.$refs[this.activePlayer].play(this.videoUrl)
  477. });
  478. },
  479. convertStop: function(callback) {
  480. var that = this;
  481. that.$refs.videoPlayer.pause()
  482. this.$axios({
  483. method: 'post',
  484. url: '/api/play/convertStop/' + this.convertKey
  485. }).then(function (res) {
  486. if (res.data.code == 0) {
  487. console.log(res.data.msg)
  488. }else {
  489. console.error(res.data.msg)
  490. }
  491. if (callback )callback();
  492. }).catch(function (e) {});
  493. that.coverPlaying = false;
  494. that.convertKey = "";
  495. // if (callback )callback();
  496. },
  497. playFromStreamInfo: function (realHasAudio, streamInfo) {
  498. this.showVideoDialog = true;
  499. this.hasaudio = realHasAudio && this.hasaudio;
  500. this.$refs[this.activePlayer].play(this.getUrlByStreamInfo(streamInfo))
  501. },
  502. close: function () {
  503. console.log('关闭视频');
  504. if (!!this.$refs[this.activePlayer]){
  505. this.$refs[this.activePlayer].pause();
  506. }
  507. this.videoUrl = '';
  508. this.coverPlaying = false;
  509. this.showVideoDialog = false;
  510. if (this.convertKey != '') {
  511. this.convertStop();
  512. }
  513. this.convertKey = ''
  514. if (this.recordPlay != '') {
  515. this.stopPlayRecord();
  516. }
  517. this.recordPlay = ''
  518. },
  519. copySharedInfo: function (data) {
  520. console.log('复制内容:' + data);
  521. this.coverPlaying = false;
  522. this.tracks = []
  523. let _this = this;
  524. this.$copyText(data).then(
  525. function (e) {
  526. _this.$message({
  527. showClose: true,
  528. message: '复制成功',
  529. type: 'success'
  530. });
  531. },
  532. function (e) {
  533. _this.$message({
  534. showClose: true,
  535. message: '复制失败,请手动复制',
  536. type: 'error'
  537. });
  538. }
  539. );
  540. },
  541. queryRecords: function () {
  542. if (!this.videoHistory.date) {
  543. return;
  544. }
  545. this.recordsLoading = true;
  546. this.videoHistory.searchHistoryResult = [];
  547. let that = this;
  548. var startTime = this.videoHistory.date + " 00:00:00";
  549. var endTime = this.videoHistory.date + " 23:59:59";
  550. this.$axios({
  551. method: 'get',
  552. url: '/api/gb_record/query/' + this.deviceId + '/' + this.channelId + '?startTime=' + startTime + '&endTime=' + endTime
  553. }).then(function (res) {
  554. console.log(res)
  555. that.recordsLoading = false;
  556. if(res.data.code === 0) {
  557. // 处理时间信息
  558. that.videoHistory.searchHistoryResult = res.data.data.recordList;
  559. }else {
  560. this.$message({
  561. showClose: true,
  562. message: res.data.msg,
  563. type: "error",
  564. });
  565. }
  566. }).catch(function (e) {
  567. console.log(e.message);
  568. // that.videoHistory.searchHistoryResult = falsificationData.recordData;
  569. });
  570. },
  571. onTimeChange: function (video) {
  572. // this.queryRecords()
  573. },
  574. playRecord: function (row) {
  575. let that = this;
  576. let startTime = row.startTime
  577. this.recordStartTime = row.startTime
  578. this.showTimeText = row.startTime.split(" ")[1]
  579. let endtime = row.endTime
  580. this.sliderTime = 0;
  581. this.seekTime = new Date(endtime).getTime() - new Date(startTime).getTime();
  582. console.log(this.seekTime)
  583. if (that.streamId != "") {
  584. that.stopPlayRecord(function () {
  585. that.streamId = "";
  586. that.playRecord(row);
  587. })
  588. } else {
  589. this.$axios({
  590. method: 'get',
  591. url: '/api/playback/start/' + this.deviceId + '/' + this.channelId + '?startTime=' + row.startTime + '&endTime=' +
  592. row.endTime
  593. }).then(function (res) {
  594. if (res.data.code === 0) {
  595. that.streamInfo = res.data.data;
  596. that.app = that.streamInfo.app;
  597. that.streamId = that.streamInfo.stream;
  598. that.mediaServerId = that.streamInfo.mediaServerId;
  599. that.ssrc = that.streamInfo.ssrc;
  600. that.videoUrl = that.getUrlByStreamInfo();
  601. }else {
  602. that.$message({
  603. showClose: true,
  604. message: res.data.msg,
  605. type: "error",
  606. });
  607. }
  608. that.recordPlay = true;
  609. });
  610. }
  611. },
  612. stopPlayRecord: function (callback) {
  613. this.$refs[this.activePlayer].pause();
  614. this.videoUrl = '';
  615. this.$axios({
  616. method: 'get',
  617. url: '/api/playback/stop/' + this.deviceId + "/" + this.channelId + "/" + this.streamId
  618. }).then(function (res) {
  619. if (callback) callback()
  620. });
  621. },
  622. downloadRecord: function (row) {
  623. let that = this;
  624. if (that.streamId != "") {
  625. that.stopDownloadRecord(function (res) {
  626. if (res.code == 0) {
  627. that.streamId = "";
  628. that.downloadRecord(row);
  629. }else {
  630. this.$message({
  631. showClose: true,
  632. message: res.data.msg,
  633. type: "error",
  634. });
  635. }
  636. })
  637. } else {
  638. this.$axios({
  639. method: 'get',
  640. url: '/api/gb_record/download/start/' + this.deviceId + '/' + this.channelId + '?startTime=' + row.startTime + '&endTime=' +
  641. row.endTime + '&downloadSpeed=4'
  642. }).then(function (res) {
  643. if (res.data.code == 0) {
  644. let streamInfo = res.data.data;
  645. that.recordPlay = false;
  646. that.$refs.recordDownload.openDialog(that.deviceId, that.channelId, streamInfo.app, streamInfo.stream, streamInfo.mediaServerId);
  647. }else {
  648. that.$message({
  649. showClose: true,
  650. message: res.data.msg,
  651. type: "error",
  652. });
  653. }
  654. });
  655. }
  656. },
  657. stopDownloadRecord: function (callback) {
  658. this.$refs[this.activePlayer].pause();
  659. this.videoUrl = '';
  660. this.$axios({
  661. method: 'get',
  662. url: '/api/gb_record/download/stop/' + this.deviceId + "/" + this.channelId+ "/" + this.streamId
  663. }).then((res)=> {
  664. if (callback) callback(res)
  665. });
  666. },
  667. ptzCamera: function (command) {
  668. console.log('云台控制:' + command);
  669. let that = this;
  670. this.$axios({
  671. method: 'post',
  672. url: '/api/ptz/control/' + this.deviceId + '/' + this.channelId + '?command=' + command + '&horizonSpeed=' + this.controSpeed + '&verticalSpeed=' + this.controSpeed + '&zoomSpeed=' + this.controSpeed
  673. }).then(function (res) {});
  674. },
  675. //////////////////////播放器事件处理//////////////////////////
  676. videoError: function (e) {
  677. console.log("播放器错误:" + JSON.stringify(e));
  678. },
  679. presetPosition: function (cmdCode, presetPos) {
  680. console.log('预置位控制:' + this.presetPos + ' : 0x' + cmdCode.toString(16));
  681. let that = this;
  682. this.$axios({
  683. method: 'post',
  684. url: '/api/ptz/front_end_command/' + this.deviceId + '/' + this.channelId + '?cmdCode=' + cmdCode + '&parameter1=0&parameter2=' + presetPos + '&combindCode2=0'
  685. }).then(function (res) {});
  686. },
  687. setSpeedOrTime: function (cmdCode, groupNum, parameter) {
  688. let that = this;
  689. let parameter2 = parameter % 256;
  690. let combindCode2 = Math.floor(parameter / 256) * 16;
  691. console.log('前端控制:0x' + cmdCode.toString(16) + ' 0x' + groupNum.toString(16) + ' 0x' + parameter2.toString(16) + ' 0x' + combindCode2.toString(16));
  692. this.$axios({
  693. method: 'post',
  694. url: '/api/ptz/front_end_command/' + this.deviceId + '/' + this.channelId + '?cmdCode=' + cmdCode + '&parameter1=' + groupNum + '&parameter2=' + parameter2 + '&combindCode2=' + combindCode2
  695. }).then(function (res) {});
  696. },
  697. setCommand: function (cmdCode, groupNum, parameter) {
  698. let that = this;
  699. console.log('前端控制:0x' + cmdCode.toString(16) + ' 0x' + groupNum.toString(16) + ' 0x' + parameter.toString(16) + ' 0x0');
  700. this.$axios({
  701. method: 'post',
  702. url: '/api/ptz/front_end_command/' + this.deviceId + '/' + this.channelId + '?cmdCode=' + cmdCode + '&parameter1=' + groupNum + '&parameter2=' + parameter + '&combindCode2=0'
  703. }).then(function (res) {});
  704. },
  705. formatTooltip: function (val) {
  706. var h = parseInt(val / 60);
  707. var hStr = h < 10 ? ("0" + h) : h;
  708. var s = val % 60;
  709. var sStr = s < 10 ? ("0" + s) : s;
  710. return h + ":" + sStr;
  711. },
  712. timeFormatter: function (row, column, cellValue, index) {
  713. return cellValue.split(" ")[1];
  714. },
  715. mergeTime: function (timeArray) {
  716. var resultArray = [];
  717. for (let i = 0; i < timeArray.length; i++) {
  718. var startTime = new Date(timeArray[i].startTime);
  719. var endTime = new Date(timeArray[i].endTime);
  720. if (i == 0) {
  721. resultArray[0] = {
  722. startTime: startTime,
  723. endTime: endTime
  724. }
  725. }
  726. for (let j = 0; j < resultArray.length; j++) {
  727. if (startTime > resultArray[j].endTime) { // 合并
  728. if (startTime - resultArray[j].endTime <= 1000) {
  729. resultArray[j].endTime = endTime;
  730. } else {
  731. resultArray[resultArray.length] = {
  732. startTime: startTime,
  733. endTime: endTime
  734. }
  735. }
  736. } else if (resultArray[j].startTime > endTime) { // 合并
  737. if (resultArray[j].startTime - endTime <= 1000) {
  738. resultArray[j].startTime = startTime;
  739. } else {
  740. resultArray[resultArray.length] = {
  741. startTime: startTime,
  742. endTime: endTime
  743. }
  744. }
  745. }
  746. }
  747. }
  748. console.log(resultArray)
  749. return resultArray;
  750. },
  751. copyUrl: function (dropdownItem){
  752. console.log(dropdownItem)
  753. this.$copyText(dropdownItem).then((e)=> {
  754. this.$message.success("成功拷贝到粘贴板");
  755. }, (e)=> {
  756. })
  757. },
  758. gbPlay(){
  759. console.log('前端控制:播放');
  760. this.$axios({
  761. method: 'get',
  762. url: '/api/playback/resume/' + this.streamId
  763. }).then((res)=> {
  764. this.$refs[this.activePlayer].play(this.videoUrl)
  765. });
  766. },
  767. gbPause(){
  768. console.log('前端控制:暂停');
  769. this.$axios({
  770. method: 'get',
  771. url: '/api/playback/pause/' + this.streamId
  772. }).then(function (res) {});
  773. },
  774. gbScale(command){
  775. console.log('前端控制:倍速 ' + command);
  776. this.$axios({
  777. method: 'get',
  778. url: `/api/playback/speed/${this.streamId }/${command}`
  779. }).then(function (res) {});
  780. },
  781. gbSeek(val){
  782. console.log('前端控制:seek ');
  783. console.log(this.seekTime);
  784. console.log(this.sliderTime);
  785. let showTime = new Date(new Date(this.recordStartTime).getTime() + this.seekTime * val / 100)
  786. let hour = showTime.getHours();
  787. let minutes = showTime.getMinutes();
  788. let seconds = showTime.getSeconds();
  789. this.showTimeText = (hour < 10?("0" + hour):hour) + ":" + (minutes<10?("0" + minutes):minutes) + ":" + (seconds<10?("0" + seconds):seconds)
  790. this.$axios({
  791. method: 'get',
  792. url: `/api/playback/seek/${this.streamId }/` + Math.floor(this.seekTime * val / 100000)
  793. }).then( (res)=> {
  794. setTimeout(()=>{
  795. this.$refs[this.activePlayer].play(this.videoUrl)
  796. }, 600)
  797. });
  798. },
  799. }
  800. };
  801. </script>
  802. <style>
  803. .control-wrapper {
  804. position: relative;
  805. width: 6.25rem;
  806. height: 6.25rem;
  807. max-width: 6.25rem;
  808. max-height: 6.25rem;
  809. border-radius: 100%;
  810. margin-top: 1.5rem;
  811. margin-left: 0.5rem;
  812. float: left;
  813. }
  814. .control-panel {
  815. position: relative;
  816. top: 0;
  817. left: 5rem;
  818. height: 11rem;
  819. max-height: 11rem;
  820. }
  821. .control-btn {
  822. display: flex;
  823. justify-content: center;
  824. position: absolute;
  825. width: 44%;
  826. height: 44%;
  827. border-radius: 5px;
  828. border: 1px solid #78aee4;
  829. box-sizing: border-box;
  830. transition: all 0.3s linear;
  831. }
  832. .control-btn:hover {
  833. cursor:pointer
  834. }
  835. .control-btn i {
  836. font-size: 20px;
  837. color: #78aee4;
  838. display: flex;
  839. justify-content: center;
  840. align-items: center;
  841. }
  842. .control-btn i:hover {
  843. cursor:pointer
  844. }
  845. .control-zoom-btn:hover {
  846. cursor:pointer
  847. }
  848. .control-round {
  849. position: absolute;
  850. top: 21%;
  851. left: 21%;
  852. width: 58%;
  853. height: 58%;
  854. background: #fff;
  855. border-radius: 100%;
  856. }
  857. .control-round-inner {
  858. position: absolute;
  859. left: 13%;
  860. top: 13%;
  861. display: flex;
  862. justify-content: center;
  863. align-items: center;
  864. width: 70%;
  865. height: 70%;
  866. font-size: 40px;
  867. color: #78aee4;
  868. border: 1px solid #78aee4;
  869. border-radius: 100%;
  870. transition: all 0.3s linear;
  871. }
  872. .control-inner-btn {
  873. position: absolute;
  874. width: 60%;
  875. height: 60%;
  876. background: #fafafa;
  877. }
  878. .control-top {
  879. top: -8%;
  880. left: 27%;
  881. transform: rotate(-45deg);
  882. border-radius: 5px 100% 5px 0;
  883. }
  884. .control-top i {
  885. transform: rotate(45deg);
  886. border-radius: 5px 100% 5px 0;
  887. }
  888. .control-top .control-inner {
  889. left: -1px;
  890. bottom: 0;
  891. border-top: 1px solid #78aee4;
  892. border-right: 1px solid #78aee4;
  893. border-radius: 0 100% 0 0;
  894. }
  895. .control-top .fa {
  896. transform: rotate(45deg) translateY(-7px);
  897. }
  898. .control-left {
  899. top: 27%;
  900. left: -8%;
  901. transform: rotate(45deg);
  902. border-radius: 5px 0 5px 100%;
  903. }
  904. .control-left i {
  905. transform: rotate(-45deg);
  906. }
  907. .control-left .control-inner {
  908. right: -1px;
  909. top: -1px;
  910. border-bottom: 1px solid #78aee4;
  911. border-left: 1px solid #78aee4;
  912. border-radius: 0 0 0 100%;
  913. }
  914. .control-left .fa {
  915. transform: rotate(-45deg) translateX(-7px);
  916. }
  917. .control-right {
  918. top: 27%;
  919. right: -8%;
  920. transform: rotate(45deg);
  921. border-radius: 5px 100% 5px 0;
  922. }
  923. .control-right i {
  924. transform: rotate(-45deg);
  925. }
  926. .control-right .control-inner {
  927. left: -1px;
  928. bottom: -1px;
  929. border-top: 1px solid #78aee4;
  930. border-right: 1px solid #78aee4;
  931. border-radius: 0 100% 0 0;
  932. }
  933. .control-right .fa {
  934. transform: rotate(-45deg) translateX(7px);
  935. }
  936. .control-bottom {
  937. left: 27%;
  938. bottom: -8%;
  939. transform: rotate(45deg);
  940. border-radius: 0 5px 100% 5px;
  941. }
  942. .control-bottom i {
  943. transform: rotate(-45deg);
  944. }
  945. .control-bottom .control-inner {
  946. top: -1px;
  947. left: -1px;
  948. border-bottom: 1px solid #78aee4;
  949. border-right: 1px solid #78aee4;
  950. border-radius: 0 0 100% 0;
  951. }
  952. .control-bottom .fa {
  953. transform: rotate(-45deg) translateY(7px);
  954. }
  955. .trank {
  956. width: 80%;
  957. height: 180px;
  958. text-align: left;
  959. padding: 0 10%;
  960. overflow: auto;
  961. }
  962. .trankInfo {
  963. width: 80%;
  964. padding: 0 10%;
  965. }
  966. </style>