devicePlayer.vue 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999
  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=rtmp&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. this.tabActiveName = tab;
  387. this.channelId = channelId;
  388. this.deviceId = deviceId;
  389. this.streamId = "";
  390. this.mediaServerId = "";
  391. this.app = "";
  392. this.videoUrl = ""
  393. if (!!this.$refs[this.activePlayer]) {
  394. this.$refs[this.activePlayer].pause();
  395. }
  396. switch (tab) {
  397. case "media":
  398. this.play(param.streamInfo, param.hasAudio)
  399. break;
  400. case "record":
  401. this.showVideoDialog = true;
  402. this.videoHistory.date = param.date;
  403. this.queryRecords()
  404. break;
  405. case "streamPlay":
  406. this.tabActiveName = "media";
  407. this.showRrecord = false;
  408. this.showPtz = false;
  409. this.play(param.streamInfo, param.hasAudio)
  410. break;
  411. case "control":
  412. break;
  413. }
  414. },
  415. timeAxisSelTime: function (val) {
  416. console.log(val)
  417. },
  418. play: function (streamInfo, hasAudio) {
  419. this.streamInfo = streamInfo;
  420. this.hasAudio = hasAudio;
  421. this.isLoging = false;
  422. // this.videoUrl = streamInfo.rtc;
  423. this.videoUrl = this.getUrlByStreamInfo();
  424. this.streamId = streamInfo.stream;
  425. this.app = streamInfo.app;
  426. this.mediaServerId = streamInfo.mediaServerId;
  427. this.playFromStreamInfo(false, streamInfo)
  428. },
  429. getUrlByStreamInfo(){
  430. if (location.protocol === "https:") {
  431. this.videoUrl = this.streamInfo[this.player[this.activePlayer][1]]
  432. }else {
  433. this.videoUrl = this.streamInfo[this.player[this.activePlayer][0]]
  434. }
  435. return this.videoUrl;
  436. },
  437. coverPlay: function () {
  438. var that = this;
  439. this.coverPlaying = true;
  440. this.$refs[this.activePlayer].pause()
  441. that.$axios({
  442. method: 'post',
  443. url: '/api/gb_record/convert/' + that.streamId
  444. }).then(function (res) {
  445. if (res.data.code == 0) {
  446. that.convertKey = res.data.key;
  447. setTimeout(()=>{
  448. that.isLoging = false;
  449. that.playFromStreamInfo(false, res.data.data);
  450. }, 2000)
  451. } else {
  452. that.isLoging = false;
  453. that.coverPlaying = false;
  454. that.$message({
  455. showClose: true,
  456. message: '转码失败',
  457. type: 'error'
  458. });
  459. }
  460. }).catch(function (e) {
  461. console.log(e)
  462. that.coverPlaying = false;
  463. that.$message({
  464. showClose: true,
  465. message: '播放错误',
  466. type: 'error'
  467. });
  468. });
  469. },
  470. convertStopClick: function() {
  471. this.convertStop(()=>{
  472. this.$refs[this.activePlayer].play(this.videoUrl)
  473. });
  474. },
  475. convertStop: function(callback) {
  476. var that = this;
  477. that.$refs.videoPlayer.pause()
  478. this.$axios({
  479. method: 'post',
  480. url: '/api/play/convertStop/' + this.convertKey
  481. }).then(function (res) {
  482. if (res.data.code == 0) {
  483. console.log(res.data.msg)
  484. }else {
  485. console.error(res.data.msg)
  486. }
  487. if (callback )callback();
  488. }).catch(function (e) {});
  489. that.coverPlaying = false;
  490. that.convertKey = "";
  491. // if (callback )callback();
  492. },
  493. playFromStreamInfo: function (realHasAudio, streamInfo) {
  494. this.showVideoDialog = true;
  495. this.hasaudio = realHasAudio && this.hasaudio;
  496. this.$refs[this.activePlayer].play(this.getUrlByStreamInfo(streamInfo))
  497. },
  498. close: function () {
  499. console.log('关闭视频');
  500. if (!!this.$refs[this.activePlayer]){
  501. this.$refs[this.activePlayer].pause();
  502. }
  503. this.videoUrl = '';
  504. this.coverPlaying = false;
  505. this.showVideoDialog = false;
  506. if (this.convertKey != '') {
  507. this.convertStop();
  508. }
  509. this.convertKey = ''
  510. if (this.recordPlay != '') {
  511. this.stopPlayRecord();
  512. }
  513. this.recordPlay = ''
  514. },
  515. copySharedInfo: function (data) {
  516. console.log('复制内容:' + data);
  517. this.coverPlaying = false;
  518. this.tracks = []
  519. let _this = this;
  520. this.$copyText(data).then(
  521. function (e) {
  522. _this.$message({
  523. showClose: true,
  524. message: '复制成功',
  525. type: 'success'
  526. });
  527. },
  528. function (e) {
  529. _this.$message({
  530. showClose: true,
  531. message: '复制失败,请手动复制',
  532. type: 'error'
  533. });
  534. }
  535. );
  536. },
  537. queryRecords: function () {
  538. if (!this.videoHistory.date) {
  539. return;
  540. }
  541. this.recordsLoading = true;
  542. this.videoHistory.searchHistoryResult = [];
  543. let that = this;
  544. var startTime = this.videoHistory.date + " 00:00:00";
  545. var endTime = this.videoHistory.date + " 23:59:59";
  546. this.$axios({
  547. method: 'get',
  548. url: '/api/gb_record/query/' + this.deviceId + '/' + this.channelId + '?startTime=' + startTime + '&endTime=' + endTime
  549. }).then(function (res) {
  550. console.log(res)
  551. if(res.data.code === 0) {
  552. // 处理时间信息
  553. that.videoHistory.searchHistoryResult = res.data.data.recordList;
  554. that.recordsLoading = false;
  555. }else {
  556. this.$message({
  557. showClose: true,
  558. message: res.data.msg,
  559. type: "error",
  560. });
  561. }
  562. }).catch(function (e) {
  563. console.log(e.message);
  564. // that.videoHistory.searchHistoryResult = falsificationData.recordData;
  565. });
  566. },
  567. onTimeChange: function (video) {
  568. // this.queryRecords()
  569. },
  570. playRecord: function (row) {
  571. let that = this;
  572. let startTime = row.startTime
  573. this.recordStartTime = row.startTime
  574. this.showTimeText = row.startTime.split(" ")[1]
  575. let endtime = row.endTime
  576. this.sliderTime = 0;
  577. this.seekTime = new Date(endtime).getTime() - new Date(startTime).getTime();
  578. console.log(this.seekTime)
  579. if (that.streamId != "") {
  580. that.stopPlayRecord(function () {
  581. that.streamId = "";
  582. that.playRecord(row);
  583. })
  584. } else {
  585. this.$axios({
  586. method: 'get',
  587. url: '/api/playback/start/' + this.deviceId + '/' + this.channelId + '?startTime=' + row.startTime + '&endTime=' +
  588. row.endTime
  589. }).then(function (res) {
  590. that.streamInfo = res.data;
  591. that.app = that.streamInfo.app;
  592. that.streamId = that.streamInfo.stream;
  593. that.mediaServerId = that.streamInfo.mediaServerId;
  594. that.ssrc = that.streamInfo.ssrc;
  595. that.videoUrl = that.getUrlByStreamInfo();
  596. that.recordPlay = true;
  597. });
  598. }
  599. },
  600. stopPlayRecord: function (callback) {
  601. this.$refs[this.activePlayer].pause();
  602. this.videoUrl = '';
  603. this.$axios({
  604. method: 'get',
  605. url: '/api/playback/stop/' + this.deviceId + "/" + this.channelId + "/" + this.streamId
  606. }).then(function (res) {
  607. if (callback) callback()
  608. });
  609. },
  610. downloadRecord: function (row) {
  611. let that = this;
  612. if (that.streamId != "") {
  613. that.stopDownloadRecord(function (res) {
  614. if (res.code == 0) {
  615. that.streamId = "";
  616. that.downloadRecord(row);
  617. }else {
  618. this.$message({
  619. showClose: true,
  620. message: res.data.msg,
  621. type: "error",
  622. });
  623. }
  624. })
  625. } else {
  626. this.$axios({
  627. method: 'get',
  628. url: '/api/gb_record/download/start/' + this.deviceId + '/' + this.channelId + '?startTime=' + row.startTime + '&endTime=' +
  629. row.endTime + '&downloadSpeed=4'
  630. }).then(function (res) {
  631. if (res.data.code == 0) {
  632. let streamInfo = res.data.data;
  633. that.recordPlay = false;
  634. that.$refs.recordDownload.openDialog(that.deviceId, that.channelId, streamInfo.app, streamInfo.stream, streamInfo.mediaServerId);
  635. }else {
  636. that.$message({
  637. showClose: true,
  638. message: res.data.msg,
  639. type: "error",
  640. });
  641. }
  642. });
  643. }
  644. },
  645. stopDownloadRecord: function (callback) {
  646. this.$refs[this.activePlayer].pause();
  647. this.videoUrl = '';
  648. this.$axios({
  649. method: 'get',
  650. url: '/api/gb_record/download/stop/' + this.deviceId + "/" + this.channelId+ "/" + this.streamId
  651. }).then((res)=> {
  652. if (callback) callback(res)
  653. });
  654. },
  655. ptzCamera: function (command) {
  656. console.log('云台控制:' + command);
  657. let that = this;
  658. this.$axios({
  659. method: 'post',
  660. url: '/api/ptz/control/' + this.deviceId + '/' + this.channelId + '?command=' + command + '&horizonSpeed=' + this.controSpeed + '&verticalSpeed=' + this.controSpeed + '&zoomSpeed=' + this.controSpeed
  661. }).then(function (res) {});
  662. },
  663. //////////////////////播放器事件处理//////////////////////////
  664. videoError: function (e) {
  665. console.log("播放器错误:" + JSON.stringify(e));
  666. },
  667. presetPosition: function (cmdCode, presetPos) {
  668. console.log('预置位控制:' + this.presetPos + ' : 0x' + cmdCode.toString(16));
  669. let that = this;
  670. this.$axios({
  671. method: 'post',
  672. url: '/api/ptz/front_end_command/' + this.deviceId + '/' + this.channelId + '?cmdCode=' + cmdCode + '&parameter1=0&parameter2=' + presetPos + '&combindCode2=0'
  673. }).then(function (res) {});
  674. },
  675. setSpeedOrTime: function (cmdCode, groupNum, parameter) {
  676. let that = this;
  677. let parameter2 = parameter % 256;
  678. let combindCode2 = Math.floor(parameter / 256) * 16;
  679. console.log('前端控制:0x' + cmdCode.toString(16) + ' 0x' + groupNum.toString(16) + ' 0x' + parameter2.toString(16) + ' 0x' + combindCode2.toString(16));
  680. this.$axios({
  681. method: 'post',
  682. url: '/api/ptz/front_end_command/' + this.deviceId + '/' + this.channelId + '?cmdCode=' + cmdCode + '&parameter1=' + groupNum + '&parameter2=' + parameter2 + '&combindCode2=' + combindCode2
  683. }).then(function (res) {});
  684. },
  685. setCommand: function (cmdCode, groupNum, parameter) {
  686. let that = this;
  687. console.log('前端控制:0x' + cmdCode.toString(16) + ' 0x' + groupNum.toString(16) + ' 0x' + parameter.toString(16) + ' 0x0');
  688. this.$axios({
  689. method: 'post',
  690. url: '/api/ptz/front_end_command/' + this.deviceId + '/' + this.channelId + '?cmdCode=' + cmdCode + '&parameter1=' + groupNum + '&parameter2=' + parameter + '&combindCode2=0'
  691. }).then(function (res) {});
  692. },
  693. formatTooltip: function (val) {
  694. var h = parseInt(val / 60);
  695. var hStr = h < 10 ? ("0" + h) : h;
  696. var s = val % 60;
  697. var sStr = s < 10 ? ("0" + s) : s;
  698. return h + ":" + sStr;
  699. },
  700. timeFormatter: function (row, column, cellValue, index) {
  701. return cellValue.split(" ")[1];
  702. },
  703. mergeTime: function (timeArray) {
  704. var resultArray = [];
  705. for (let i = 0; i < timeArray.length; i++) {
  706. var startTime = new Date(timeArray[i].startTime);
  707. var endTime = new Date(timeArray[i].endTime);
  708. if (i == 0) {
  709. resultArray[0] = {
  710. startTime: startTime,
  711. endTime: endTime
  712. }
  713. }
  714. for (let j = 0; j < resultArray.length; j++) {
  715. if (startTime > resultArray[j].endTime) { // 合并
  716. if (startTime - resultArray[j].endTime <= 1000) {
  717. resultArray[j].endTime = endTime;
  718. } else {
  719. resultArray[resultArray.length] = {
  720. startTime: startTime,
  721. endTime: endTime
  722. }
  723. }
  724. } else if (resultArray[j].startTime > endTime) { // 合并
  725. if (resultArray[j].startTime - endTime <= 1000) {
  726. resultArray[j].startTime = startTime;
  727. } else {
  728. resultArray[resultArray.length] = {
  729. startTime: startTime,
  730. endTime: endTime
  731. }
  732. }
  733. }
  734. }
  735. }
  736. console.log(resultArray)
  737. return resultArray;
  738. },
  739. copyUrl: function (dropdownItem){
  740. console.log(dropdownItem)
  741. this.$copyText(dropdownItem).then((e)=> {
  742. this.$message.success("成功拷贝到粘贴板");
  743. }, (e)=> {
  744. })
  745. },
  746. gbPlay(){
  747. console.log('前端控制:播放');
  748. this.$axios({
  749. method: 'get',
  750. url: '/api/playback/resume/' + this.streamId
  751. }).then((res)=> {
  752. this.$refs[this.activePlayer].play(this.videoUrl)
  753. });
  754. },
  755. gbPause(){
  756. console.log('前端控制:暂停');
  757. this.$axios({
  758. method: 'get',
  759. url: '/api/playback/pause/' + this.streamId
  760. }).then(function (res) {});
  761. },
  762. gbScale(command){
  763. console.log('前端控制:倍速 ' + command);
  764. this.$axios({
  765. method: 'get',
  766. url: `/api/playback/speed/${this.streamId }/${command}`
  767. }).then(function (res) {});
  768. },
  769. gbSeek(val){
  770. console.log('前端控制:seek ');
  771. console.log(this.seekTime);
  772. console.log(this.sliderTime);
  773. let showTime = new Date(new Date(this.recordStartTime).getTime() + this.seekTime * val / 100)
  774. let hour = showTime.getHours();
  775. let minutes = showTime.getMinutes();
  776. let seconds = showTime.getSeconds();
  777. this.showTimeText = (hour < 10?("0" + hour):hour) + ":" + (minutes<10?("0" + minutes):minutes) + ":" + (seconds<10?("0" + seconds):seconds)
  778. this.$axios({
  779. method: 'get',
  780. url: `/api/playback/seek/${this.streamId }/` + Math.floor(this.seekTime * val / 100000)
  781. }).then( (res)=> {
  782. setTimeout(()=>{
  783. this.$refs[this.activePlayer].play(this.videoUrl)
  784. }, 600)
  785. });
  786. },
  787. }
  788. };
  789. </script>
  790. <style>
  791. .control-wrapper {
  792. position: relative;
  793. width: 6.25rem;
  794. height: 6.25rem;
  795. max-width: 6.25rem;
  796. max-height: 6.25rem;
  797. border-radius: 100%;
  798. margin-top: 1.5rem;
  799. margin-left: 0.5rem;
  800. float: left;
  801. }
  802. .control-panel {
  803. position: relative;
  804. top: 0;
  805. left: 5rem;
  806. height: 11rem;
  807. max-height: 11rem;
  808. }
  809. .control-btn {
  810. display: flex;
  811. justify-content: center;
  812. position: absolute;
  813. width: 44%;
  814. height: 44%;
  815. border-radius: 5px;
  816. border: 1px solid #78aee4;
  817. box-sizing: border-box;
  818. transition: all 0.3s linear;
  819. }
  820. .control-btn:hover {
  821. cursor:pointer
  822. }
  823. .control-btn i {
  824. font-size: 20px;
  825. color: #78aee4;
  826. display: flex;
  827. justify-content: center;
  828. align-items: center;
  829. }
  830. .control-btn i:hover {
  831. cursor:pointer
  832. }
  833. .control-zoom-btn:hover {
  834. cursor:pointer
  835. }
  836. .control-round {
  837. position: absolute;
  838. top: 21%;
  839. left: 21%;
  840. width: 58%;
  841. height: 58%;
  842. background: #fff;
  843. border-radius: 100%;
  844. }
  845. .control-round-inner {
  846. position: absolute;
  847. left: 13%;
  848. top: 13%;
  849. display: flex;
  850. justify-content: center;
  851. align-items: center;
  852. width: 70%;
  853. height: 70%;
  854. font-size: 40px;
  855. color: #78aee4;
  856. border: 1px solid #78aee4;
  857. border-radius: 100%;
  858. transition: all 0.3s linear;
  859. }
  860. .control-inner-btn {
  861. position: absolute;
  862. width: 60%;
  863. height: 60%;
  864. background: #fafafa;
  865. }
  866. .control-top {
  867. top: -8%;
  868. left: 27%;
  869. transform: rotate(-45deg);
  870. border-radius: 5px 100% 5px 0;
  871. }
  872. .control-top i {
  873. transform: rotate(45deg);
  874. border-radius: 5px 100% 5px 0;
  875. }
  876. .control-top .control-inner {
  877. left: -1px;
  878. bottom: 0;
  879. border-top: 1px solid #78aee4;
  880. border-right: 1px solid #78aee4;
  881. border-radius: 0 100% 0 0;
  882. }
  883. .control-top .fa {
  884. transform: rotate(45deg) translateY(-7px);
  885. }
  886. .control-left {
  887. top: 27%;
  888. left: -8%;
  889. transform: rotate(45deg);
  890. border-radius: 5px 0 5px 100%;
  891. }
  892. .control-left i {
  893. transform: rotate(-45deg);
  894. }
  895. .control-left .control-inner {
  896. right: -1px;
  897. top: -1px;
  898. border-bottom: 1px solid #78aee4;
  899. border-left: 1px solid #78aee4;
  900. border-radius: 0 0 0 100%;
  901. }
  902. .control-left .fa {
  903. transform: rotate(-45deg) translateX(-7px);
  904. }
  905. .control-right {
  906. top: 27%;
  907. right: -8%;
  908. transform: rotate(45deg);
  909. border-radius: 5px 100% 5px 0;
  910. }
  911. .control-right i {
  912. transform: rotate(-45deg);
  913. }
  914. .control-right .control-inner {
  915. left: -1px;
  916. bottom: -1px;
  917. border-top: 1px solid #78aee4;
  918. border-right: 1px solid #78aee4;
  919. border-radius: 0 100% 0 0;
  920. }
  921. .control-right .fa {
  922. transform: rotate(-45deg) translateX(7px);
  923. }
  924. .control-bottom {
  925. left: 27%;
  926. bottom: -8%;
  927. transform: rotate(45deg);
  928. border-radius: 0 5px 100% 5px;
  929. }
  930. .control-bottom i {
  931. transform: rotate(-45deg);
  932. }
  933. .control-bottom .control-inner {
  934. top: -1px;
  935. left: -1px;
  936. border-bottom: 1px solid #78aee4;
  937. border-right: 1px solid #78aee4;
  938. border-radius: 0 0 100% 0;
  939. }
  940. .control-bottom .fa {
  941. transform: rotate(-45deg) translateY(7px);
  942. }
  943. .trank {
  944. width: 80%;
  945. height: 180px;
  946. text-align: left;
  947. padding: 0 10%;
  948. overflow: auto;
  949. }
  950. .trankInfo {
  951. width: 80%;
  952. padding: 0 10%;
  953. }
  954. </style>