海康网页预览ws取流预览5min歧义


指5min内url链接没使用,链接作废,用了只要不刷新一直能用
另外不能作为固定永久链接。因为一刷新wbscoket就断了
ws取流预览官方教程:
或搜【视频】查找相关所需教程
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
预览用海康官方H5player播放器网页预览
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播放器同时播放多画面

<!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],//播放画面个数实列
            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() {
            // 设置播放容器的宽高并监听窗口大小变化
            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'
              }
            })

            // 事件回调绑定
            this.players[index].JS_SetWindowControlCallback({
              windowEventSelect: function (iWndIndex) {
                //插件选中窗口回调
                console.log('windowSelect callback: ', iWndIndex)
              },
              pluginErrorHandler: function (iWndIndex, iErrorCode, oError) {
                //插件错误回调
                console.log('pluginError callback: ', iWndIndex, iErrorCode, oError)
              },
              windowEventOver: function (iWndIndex) {
                //鼠标移过回调
                //console.log(iWndIndex);
              },
              windowEventOut: function (iWndIndex) {
                //鼠标移出回调
                //console.log(iWndIndex);
              },
              windowEventUp: function (iWndIndex) {
                //鼠标mouseup事件回调
                //console.log(iWndIndex);
              },
              windowFullCcreenChange: function (bFull) {
                //全屏切换回调
                console.log('fullScreen callback: ', bFull)
              },
              firstFrameDisplay: function (iWndIndex, iWidth, iHeight) {
                //首帧显示回调
                console.log('firstFrame loaded callback: ', iWndIndex, iWidth, iHeight)
              },
              performanceLack: function () {
                //性能不足回调
                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)
              }
            )
          },
          /* 预览&对讲 */
          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推流地址或手动填入测试
          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, '获取结果', 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访问,需要安装证书才能显示。
证书在超脑自带,替换对应ip 回车安装下。
https://192.168.xx.xx/nginxService/v1/download/InstallRootCert.exe

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 226,913评论 6 527
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 97,710评论 3 412
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 174,561评论 0 373
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 62,278评论 1 306
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 71,080评论 6 405
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 54,604评论 1 320
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 42,698评论 3 434
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 41,847评论 0 285
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 48,361评论 1 329
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 40,330评论 3 353
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 42,487评论 1 365
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 38,044评论 5 355
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 43,738评论 3 342
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 34,134评论 0 25
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 35,378评论 1 281
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 51,053评论 3 385
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 47,471评论 2 370

推荐阅读更多精彩内容