海康網(wǎng)頁(yè)預(yù)覽ws取流預(yù)覽5min歧義


指5min內(nèi)url鏈接沒使用,鏈接作廢,用了只要不刷新一直能用
另外不能作為固定永久鏈接。因?yàn)橐凰⑿聎bscoket就斷了
ws取流預(yù)覽官方教程:
或搜【視頻】查找相關(guān)所需教程
https://hkrobot.hikvision.com/servlet/WBShow?action=sac&sysNum=145716889796196&wbId=-100&FromUserName=API_1ef74560646b43477658fce6b08e330d&question=%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%9814%E3%80%81%E5%A6%82%E4%BD%95%E8%BF%9B%E8%A1%8C%E6%B5%B7%E5%BA%B7%E7%A7%81%E6%9C%89%E5%8D%8F%E8%AE%AEws%E5%8F%96%E6%B5%81%E5%8F%8A%E5%8F%96%E6%B5%81url%E6%97%A0%E6%B3%95%E6%92%AD%E6%94%BE%E9%97%AE%E9%A2%98%E5%A4%84%E7%90%86&fid=&sId=781709&MsgType=workflow
取流url文檔 :https://open.hikvision.com/docs/docId?productId=5c67f1e2f05948198c909700&version=%2Ff95e951cefc54578b523d1738f65f0a1&tagPath=API%E5%88%97%E8%A1%A8-%E8%A7%86%E9%A2%91%E5%BA%94%E7%94%A8%E6%9C%8D%E5%8A%A1-%E8%A7%86%E9%A2%91%E8%83%BD%E5%8A%9B#b5bd6fd9
預(yù)覽用??倒俜紿5player播放器網(wǎng)頁(yè)預(yù)覽
https://hkrobot.hikvision.com/servlet/WBShow?action=sac&wbId=-100&sysNum=145716889796196&FromUserName=API_1ef74560646b43477658fce6b08e330d&sId=828889&subId=479621
歧義具體參考
http://www.taodudu.cc/news/show-1129118.html?action=onClick
海康h5 player播放器同時(shí)播放多畫面

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>H5playerVue</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }

      #player {
        width: 100vw;
        height: 100vh;
      }
      #app {
        display: none;
      }

      .actions {
        padding-left: 8px;
      }

      .ant-form-item {
        margin-bottom: 8px;
      }
      .ant-btn {
        margin-right: 2px;
      }

      .icon-wrapper {
        position: relative;
        padding-left: 20px;
      }
      .icon-wrapper .anticon {
        position: absolute;
        top: -2px;
        width: 16px;
        height: 16px;
        line-height: 1;
        font-size: 16px;
        left: 0;
      }

      ::-webkit-media-controls {
        display: none !important;
      }

      * {
        margin: 0;
        padding: 0;
      }

      .flex {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-start;
        align-items: flex-start;
      }

      .player {
        width: 25%;
        height: calc(100vh / 3);
        /* height: 100vh; */
      }
    </style>
  </head>
  <body>
    <div id="app">
      <div class="flex">
        <div class="player" v-for="(player, index) in players.length" :id="'player' + index"></div>
      </div>
    </div>
    <script src="./vue.js"></script>
    <script src="./h5player.min.js"></script>
    <script src="./axios.min.js"></script>
    <script>
      const MSE_IS_SUPPORT = false // 是否支持mse
      const app = new Vue({
        el: '#app',
        // components: { Log },
        data() {
          return {
            player: null,
            players: [null, null, null, null, null, null, null, null, null, null, null, null],//播放畫面?zhèn)€數(shù)實(shí)列
            urls: [],
            splitNum: 1,
            tabActive: MSE_IS_SUPPORT ? 'mse' : 'decoder',
            url: null,
            playback: {
              rate: ''
            },
            muted: true
          }
        },
        computed: {
          mode: function () {
            return this.tabActive === 'mse' ? 0 : 1
          }
        },
        methods: {
          init() {
            // 設(shè)置播放容器的寬高并監(jiān)聽窗口大小變化
            window.addEventListener('resize', () => {
              this.player.JS_Resize()
            })
          },
          createPlayer(index) {
            this.players[index] = new window.JSPlugin({
              szId: 'player' + index,
              szBasePath: './',
              // iMaxSplit: 4,
              iCurrentSplit: 1,
              openDebug: true,
              oStyle: {
                borderSelect: '#000'
              }
            })

            // 事件回調(diào)綁定
            this.players[index].JS_SetWindowControlCallback({
              windowEventSelect: function (iWndIndex) {
                //插件選中窗口回調(diào)
                console.log('windowSelect callback: ', iWndIndex)
              },
              pluginErrorHandler: function (iWndIndex, iErrorCode, oError) {
                //插件錯(cuò)誤回調(diào)
                console.log('pluginError callback: ', iWndIndex, iErrorCode, oError)
              },
              windowEventOver: function (iWndIndex) {
                //鼠標(biāo)移過回調(diào)
                //console.log(iWndIndex);
              },
              windowEventOut: function (iWndIndex) {
                //鼠標(biāo)移出回調(diào)
                //console.log(iWndIndex);
              },
              windowEventUp: function (iWndIndex) {
                //鼠標(biāo)mouseup事件回調(diào)
                //console.log(iWndIndex);
              },
              windowFullCcreenChange: function (bFull) {
                //全屏切換回調(diào)
                console.log('fullScreen callback: ', bFull)
              },
              firstFrameDisplay: function (iWndIndex, iWidth, iHeight) {
                //首幀顯示回調(diào)
                console.log('firstFrame loaded callback: ', iWndIndex, iWidth, iHeight)
              },
              performanceLack: function () {
                //性能不足回調(diào)
                console.log('performanceLack callback: ')
              }
            })
          },
          arrangeWindow() {
            let splitNum = this.splitNum
            this.player.JS_ArrangeWindow(splitNum).then(
              () => {
                console.log(`arrangeWindow to ${splitNum}x${splitNum} success`)
              },
              e => {
                console.error(e)
              }
            )
          },
          /* 預(yù)覽&對(duì)講 */
          realplay(index) {
            let player = this.players[index]
            let playURL = this.urls[index]
            let { mode } = this
            index = player.currentWindowIndex
            // response.data[0].playUrl
            player.JS_Play(playURL, { playURL, mode }, index).then(
              () => {
                console.log('realplay success')
              },
              e => {
                console.error(e)
              }
            )
          },
          stopPlay() {
            this.player.JS_Stop().then(
              () => {
                this.playback.rate = 0
                console.log('stop realplay success')
              },
              e => {
                console.error(e)
              }
            )
          },
          stopAllPlay() {
            this.player.JS_StopRealPlayAll().then(
              () => {
                this.playback.rate = 0
                console.log('stopAllPlay success')
              },
              e => {
                console.error(e)
              }
            )
          },
          playbackSlow() {
            this.player.JS_Slow().then(
              rate => {
                this.playback.rate = rate
              },
              e => {
                console.error(e)
              }
            )
          },
          playbackFast() {
            this.player.JS_Fast().then(
              rate => {
                this.playback.rate = rate
              },
              e => {
                console.error(e)
              }
            )
          },
          frameForward() {
            this.player.JS_FrameForward(this.player.currentWindowIndex).then(
              () => {
                this.playback.rate = 1
                console.log('frameForward success')
              },
              e => {
                console.error(e)
              }
            )
          },
          /* 聲音、抓圖、錄像 */
          openSound() {
            this.player.JS_OpenSound().then(
              () => {
                console.log('openSound success')
                this.muted = false
              },
              e => {
                console.error(e)
              }
            )
          },
          closeSound() {
            this.player.JS_CloseSound().then(
              () => {
                console.log('closeSound success')
                this.muted = true
              },
              e => {
                console.error(e)
              }
            )
          },
          setVolume(value) {
            let player = this.player,
              index = player.currentWindowIndex
            this.player.JS_SetVolume(index, value).then(
              () => {
                console.log('setVolume success', value)
              },
              e => {
                console.error(e)
              }
            )
          },
          capture(imageType) {
            let player = this.player,
              index = player.currentWindowIndex

            player.JS_CapturePicture(index, 'img', imageType).then(
              () => {
                console.log('capture success', imageType)
              },
              e => {
                console.error(e)
              }
            )
          },
          recordStart(type) {
            const codeMap = { MP4: 5, PS: 2 }
            let player = this.player,
              index = player.currentWindowIndex,
              fileName = `${moment().format('YYYYMMDDHHmm')}.mp4`
            typeCode = codeMap[type]

            player.JS_StartSaveEx(index, fileName, typeCode).then(
              () => {
                console.log('record start ...')
              },
              e => {
                console.error(e)
              }
            )
          },
          recordStop() {
            let player = this.player
            index = player.currentWindowIndex

            player.JS_StopSave(index).then(
              () => {
                console.log('record stoped, saving ...')
              },
              e => {
                console.error(e)
              }
            )
          },
          /* 電子放大、智能信息 */
          enlarge() {
            let player = this.player,
              index = player.currentWindowIndex

            player.JS_EnableZoom(index).then(
              () => {
                console.log('enlarge start..., select range...')
              },
              e => {
                console.error(e)
              }
            )
          },
          enlargeClose() {
            let player = this.player,
              index = player.currentWindowIndex

            player.JS_DisableZoom(index).then(
              () => {
                console.log('enlargeClose success')
              },
              e => {
                console.error(e)
              }
            )
          },
          intellectTrigger(openFlag) {
            let player = this.player,
              index = player.currentWindowIndex

            let result = player.JS_RenderALLPrivateData(index, openFlag)
            console.log(
              `${openFlag ? 'open' : 'close'} intellect ${result === 1 ? 'success' : 'failed'}`
            )
          },
          getvideoInfo() {
            let player = this.player,
              index = player.currentWindowIndex

            player.JS_GetVideoInfo(index).then(function (videoInfo) {
              console.log('videoInfo:', videoInfo)
            })
          },
          getOSDTime() {
            let player = this.player,
              index = player.currentWindowIndex

            player.JS_GetOSDTime(index).then(function (time) {
              console.log('osdTime:', new Date(time))
            })
          }
        },
        mounted() {
          this.$el.style.setProperty('display', 'block')
          this.init()
          let self = this
//  接口為獲取ws推流地址或手動(dòng)填入測(cè)試
          axios
            .get(
              'xx/',
              {
                params: {
                  streamType: 1,
                  protocol: 'ws'
                }
              }
            )
            .then(function (response) {
              // handle success
              let data = response.data
              self.urls = response.data.map(item => {
                return item.playUrl
              })
              console.log('地址', self.urls)
              console.log(0, '獲取結(jié)果', JSON.stringify(data))
              for (let i = 0; i < self.players.length; i++) {
                self.createPlayer(i)
                self.realplay(i)
              }
              //
            })
            .catch(function (error) {
              // handle error
              console.log(3, error)
            })
        }
      })
    </script>
  </body>
</html>

wss取流,如果用https訪問,需要安裝證書才能顯示。
證書在超腦自帶,替換對(duì)應(yīng)ip 回車安裝下。
https://192.168.xx.xx/nginxService/v1/download/InstallRootCert.exe

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容