国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

45 對接??狄曨l九宮格的實現(xiàn)

這篇具有很好參考價值的文章主要介紹了45 對接??狄曨l九宮格的實現(xiàn)。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

前言

這里主要是 來看一下 海康視頻 的一個九宮格播放的需求

然后 在實際使用的過程中產(chǎn)生了一些問題, 比如 增加一個視頻, 應(yīng)該只增量請求這一個視頻的服務(wù), 而一些實現(xiàn)下是全量請求了 整個視頻列表的服務(wù)

另外 就是全屏播放, 如果是 自己寫樣式來實現(xiàn) 全屏播放, 可能需要 重新創(chuàng)建 ??档膒layer, 進而 需要重新請求 ??档囊曨l服務(wù)

另外 還有 cpu, 內(nèi)存占用過高的情況, 然后 還有一些疑似 內(nèi)存泄露的情況

這里 調(diào)整一個版本 記錄一下

以下有一些版本, 一個是自定義實現(xiàn)九宮格, 這樣做的問題 還是挺多的, 以上的問題基本上都占了, 然后另外一個版本是 直接使用 ??底约禾峁┑?api 來實現(xiàn) 九宮格, 會稍微好一些

?文章來源地址http://www.zghlxwxcb.cn/news/detail-851660.html

?

整體來說, 一個比較良好的情況是, 否則的話 可能會出現(xiàn)一些 較高的資源占用的問題

  1. 新增一個視頻的時候, 僅僅增量請求這一個視頻的數(shù)據(jù), 增量的和??到⑦B接
  2. 全屏的時候 使用海康的 api, 它自己已經(jīng)實現(xiàn)了 自適應(yīng), 否則 自己處理的話 自適應(yīng)有可能需要重新和??到⑦B接, 重新渲染
  3. 盡量避免 并發(fā) 和請求??档慕涌? 經(jīng)常會崩潰, 盡量避免 頻繁的和??禂嚅_視頻連接, 重新創(chuàng)建視頻連接

?

?

自己自定義九宮格

這個就相當(dāng)于是 海康的視頻播放器只播放一個視頻

然后 這里是 循環(huán) codeUrlList, 一個視頻對應(yīng)于一個 player, 雖然同時 播放了多個 player 但是 實際上核心占用資源的貌似是其中一個

key 需要指定, 否則 在一些需要重新渲染 ??祊layer 的場景下面, 模型改變了 但是每一個 div 內(nèi)部的 player 的 dom 不會重新渲染, 可能會導(dǎo)致 視頻錯位等問題

這個 問題就是需要自己實現(xiàn)全屏的樣式, 以及全拼的時候需要全部重新渲染一次, 才能適應(yīng)全屏之后的窗口

其他的 增量的獲取海康服務(wù), 避免并發(fā)的請求??到涌?就需要自己處理了

以下的測試代碼 看 (!singlePlayer) 部分

?

業(yè)務(wù)組件如下

<template>
  <div class="indexDiv">
    <div v-if="!singlePlayer" v-for="item in codeUrlList" :key="item.code" style="width:400px; display: inline; float:left;">
      <Player :palyer-code="item.code" :play-url="item.url"></Player>
    </div>
  
    <PlayerSplitByHk ref="playerHk" v-if="singlePlayer"></PlayerSplitByHk>
    <button @click="handleFullScreen" >全屏</button>
  </div>
</template>

<script>

import Player from "./Player.vue"
import PlayerSplitByHk from "./PlayerSplitByHk.vue"

export default {
  name: "Index",
  components: {
    Player,
    PlayerSplitByHk,
  },
  data() {
    return {
    singlePlayer: false,
    codeUrlList: [{"code":"61092100561310001001","url":"ws://112.110.110.109/openUrl/KG6aIkE"},{"code":"61102600581328004001","url":"ws://112.110.110.109:559/openUrl/KHubaKc"},{"code":"61092200561310001001","url":"ws://112.110.110.109:559/openUrl/KIs4xbO"},{"code":"61092200561310001002","url":"ws://112.110.110.109:559/openUrl/KJcCKwo"},{"code":"61092200561310002701","url":"ws://112.110.110.109/openUrl/KK6g812"},{"code":"61092200561310001901","url":"ws://112.110.110.109:559/openUrl/KL11U1W"},{"code":"61092800561310002101","url":"ws://112.110.110.109:559/openUrl/KLJjkk0"},{"code":"61092800561310002402","url":"ws://112.110.110.109:559/openUrl/KMu98ME"},{"code":"61092800561310002901","url":"ws://112.110.110.109/openUrl/KNaIYik"}]
    };
  },
  mounted() {
    // test for hk sudoku
    if(this.singlePlayer) {
      this.$refs.playerHk.updateCodeUrlList(this.codeUrlList)
      // call updateCodeUrlList if codeUrlList updated

      let _this = this
      setTimeout(function() {
        let updatedCodeUrlList = []
        _this.codeUrlList.map(ele => updatedCodeUrlList.push(ele))
        updatedCodeUrlList.splice(5, 3)
        _this.$refs.playerHk.updateCodeUrlList(updatedCodeUrlList)
        console.log(" splice with idx 6, 7, 8 ")
        console.log(" ----------------------------- ")
      }, 5000)
      setTimeout(function() {
        let updatedCodeUrlList = []
        _this.codeUrlList.map(ele => updatedCodeUrlList.push(ele))
        updatedCodeUrlList.splice(5, 3)
        updatedCodeUrlList.push({code: "code1", url: "url1"})
        updatedCodeUrlList.push({code: "code2", url: "url2"})
        _this.$refs.playerHk.updateCodeUrlList(updatedCodeUrlList)
        console.log(" push url1, url2 ")
        console.log(" ----------------------------- ")
      }, 10000)
    }
  },
  methods: {
    handleFullScreen() {
      // test for hk sudoku
      if(this.singlePlayer) {
        this.$refs.playerHk.handleFullScreen()
      }
    }
  }
}

</script>

<style scoped>

</style>

?

視頻播放組件如下

<template>
  <div clas="outerDiv" >
    <div class="main" :id="'playerDiv' + this.palyerCode"  ></div>
  </div>
</template>

<script>

export default {
  name: "Player",
  props: {
    palyerCode: {
      type: String,
      default: "",
    },
    playUrl: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      player: null
    };
  },
  mounted() {
    this.createPlayer()
    this.startPlay()
  },
  methods: {
    createPlayer() {
      this.player = new window.JSPlugin({
        szId: 'playerDiv' + this.palyerCode,
        szBasePath: "./",
        iMaxSplit: 4,
        iCurrentSplit: 1,
        openDebug: true,
        oStyle: {
          borderSelect: '#000',
        }
      })

      // 事件回調(diào)綁定
    let _this = this
      this.player.JS_SetWindowControlCallback({
        windowEventSelect: function (iWndIndex) {  //插件選中窗口回調(diào)
          console.log('windowSelect callback: ', iWndIndex);
          _this.player.JS_Stop(iWndIndex).then(
            () => { console.log('stop play ' + iWndIndex + ' success') },
            e => { console.error(e) }
          )
        },
        pluginErrorHandler: function (iWndIndex, iErrorpalyerCode, oError) {  //插件錯誤回調(diào)
          console.log('pluginError callback: ', iWndIndex, iErrorpalyerCode, oError);
        },
        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: ');
        }
      });
    },
    startPlay() {
      let playURL = this.playUrl
      let model = 1
      console.log(" start replay with url : " + playURL)
      // this.player.JS_Play(playURL, { playURL, model }, 0).then(
      //     () => { console.log('realplay success') },
      //     e => { console.error(e) }
      // )
    }
  }
}

</script>

<style scoped>

</style>

?

?

使用 hik 提供的 api 實現(xiàn)九宮格

這里的九宮格的實現(xiàn)就是直接基于 hk 的 api 了, 比如這里的 this.player.JS_ArrangeWindow, this.player.JS_Play?

然后 全屏基于 this.player.JS_FullScreenDisplay, 然后 全拼的狀態(tài)可以通過 windowFullCcreenChange 進行獲取

一些 常見的回調(diào)函數(shù), 也在 demo 中有體現(xiàn)

然后 降低客戶端和??捣?wù)器這邊的開銷的處理, 主要是如下的 更新前后的視頻列表, 如果目標索引的視頻變了, 才重新發(fā)起請求, 重新建立視頻連接

?

這樣的話 開始的時候點擊九個視頻, 資源占用大概是 cpu100%, 內(nèi)存差不多是 500M 左右, 然后 隨著時間的推移, 主項目的js引擎[不是海康player的js引擎] 占用內(nèi)存逐漸升高, 這個具體就得看這個 player 的問題了, 然后刷新 Index.vue 的頁面, 這個內(nèi)存占用 依然存在

這里 就不深究了

?

業(yè)務(wù)組件如下

<template>
  <div class="indexDiv">
    <div v-if="!singlePlayer" v-for="item in codeUrlList" :key="item.code" style="width:400px; display: inline; float:left;">
      <Player :palyer-code="item.code" :play-url="item.url"></Player>
    </div>
  
    <PlayerSplitByHk ref="playerHk" v-if="singlePlayer"></PlayerSplitByHk>
    <button @click="handleFullScreen" >全屏</button>
  </div>
</template>

<script>

import Player from "./Player.vue"
import PlayerSplitByHk from "./PlayerSplitByHk.vue"

export default {
  name: "Index",
  components: {
    Player,
    PlayerSplitByHk,
  },
  data() {
    return {
    singlePlayer: false,
    codeUrlList: [{"code":"61092100561310001001","url":"ws://112.110.110.109/openUrl/KG6aIkE"},{"code":"61102600581328004001","url":"ws://112.110.110.109:559/openUrl/KHubaKc"},{"code":"61092200561310001001","url":"ws://112.110.110.109:559/openUrl/KIs4xbO"},{"code":"61092200561310001002","url":"ws://112.110.110.109:559/openUrl/KJcCKwo"},{"code":"61092200561310002701","url":"ws://112.110.110.109/openUrl/KK6g812"},{"code":"61092200561310001901","url":"ws://112.110.110.109:559/openUrl/KL11U1W"},{"code":"61092800561310002101","url":"ws://112.110.110.109:559/openUrl/KLJjkk0"},{"code":"61092800561310002402","url":"ws://112.110.110.109:559/openUrl/KMu98ME"},{"code":"61092800561310002901","url":"ws://112.110.110.109/openUrl/KNaIYik"}]
    };
  },
  mounted() {
    // test for hk sudoku
    if(this.singlePlayer) {
      this.$refs.playerHk.updateCodeUrlList(this.codeUrlList)
      // call updateCodeUrlList if codeUrlList updated

      let _this = this
      setTimeout(function() {
        let updatedCodeUrlList = []
        _this.codeUrlList.map(ele => updatedCodeUrlList.push(ele))
        updatedCodeUrlList.splice(5, 3)
        _this.$refs.playerHk.updateCodeUrlList(updatedCodeUrlList)
        console.log(" splice with idx 6, 7, 8 ")
        console.log(" ----------------------------- ")
      }, 5000)
      setTimeout(function() {
        let updatedCodeUrlList = []
        _this.codeUrlList.map(ele => updatedCodeUrlList.push(ele))
        updatedCodeUrlList.splice(5, 3)
        updatedCodeUrlList.push({code: "code1", url: "url1"})
        updatedCodeUrlList.push({code: "code2", url: "url2"})
        _this.$refs.playerHk.updateCodeUrlList(updatedCodeUrlList)
        console.log(" push url1, url2 ")
        console.log(" ----------------------------- ")
      }, 10000)
    }
  },
  methods: {
    handleFullScreen() {
      // test for hk sudoku
      if(this.singlePlayer) {
        this.$refs.playerHk.handleFullScreen()
      }
    }
  }
}

</script>

<style scoped>

</style>

?

視頻播放組件如下

<template>
  <div class="outerDiv" >
    <div class="main" id="playerDiv" ></div>
  </div>
</template>

<script>

export default {
  name: "PlayerSplitByHk",
  props: {
  },
  data() {
    return {
      player: null,
      videoListMax: 0,
      isFirstClick: false,
      codeUrlList: null,
    };
  },
  mounted() {
    this.createPlayer()
  },
  methods: {
    updateCodeUrlList(newCodeUrlList) {
      let oldCodeUrlList = this.codeUrlList
      this.codeUrlList = newCodeUrlList
      this.videoListMax = Math.max(this.videoListMax, newCodeUrlList.length)
      let matrixLen = newCodeUrlList.length > 4 ? 3 : (newCodeUrlList.length > 1 ? 2 : 1)

      this.isFirstClick = true
      this.player.JS_ArrangeWindow(matrixLen)
      for(let i=newCodeUrlList.length; i<this.videoListMax; i++) {
        console.log(" stop replay with idx : " + i)
        this.player.JS_Stop(i);
      }

      for(let i=0; i<newCodeUrlList.length; i++) {
        let newItem = newCodeUrlList[i]
        let oldItem = oldCodeUrlList && oldCodeUrlList[i]
        if((!oldItem) || (oldItem.code !== newItem.code)) {
          this.startPlay(i)
        }
      }
    },
    handleFullScreen() {
      this.player.JS_FullScreenDisplay(true).then(
          () => { console.log(`wholeFullScreen success`) },
          e => { console.error(e) }
      )
    },
    createPlayer() {
      this.player = new window.JSPlugin({
        szId: 'playerDiv',
        szBasePath: "/static",
        iMaxSplit: 9,
        iCurrentSplit: 1,
        iWidth: 400,
        iHeight: 300,
        openDebug: true,
        oStyle: {
          // border: '#green',
          // borderSelect: '#ffcc00',
        }
      })

    // 事件回調(diào)綁定
    let _this = this
      this.player.JS_SetWindowControlCallback({
        windowEventSelect: function (iWndIndex) {  //插件選中窗口回調(diào)
          if(_this.isFirstClick) {
            _this.isFirstClick = false
            return ;
          }
          console.log(" do what you want ")
        },
        pluginErrorHandler: function (iWndIndex, iErrorpalyerCode, oError) {
          console.log('pluginError callback: ', iWndIndex, iErrorpalyerCode, oError);
        },
        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: ');
        }
      });
    },
    startPlay(idx) {
      let playURL = this.codeUrlList[idx].url
      let model = 1
      console.log(" start replay with idx : " + idx)
      // this.player.JS_Play(playURL, { playURL, model }, idx).then(
      //     () => { console.log('realplay success') },
      //     e => { console.error(e) }
      // )
    }
  }
}

</script>

<style scoped>

</style>

?

?

完?

?

?

?

到了這里,關(guān)于45 對接??狄曨l九宮格的實現(xiàn)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • vue2 對接 ??禂z像頭插件 (視頻WEB插件 V1.5.2)

    vue2 對接 ??禂z像頭插件 (視頻WEB插件 V1.5.2)

    前言 ??狄曨l插件v.1.5.2版本運行環(huán)境需要安裝插件VideoWebPlugin.exe,對瀏覽器也有兼容性要求,具體看官方文檔 對應(yīng)下載插件 去??倒倬W(wǎng)下載插件 里面有dome等其他需要用到的 地址: 安裝插件 打開下載的文件里的bin文件 安裝一下VideoWebPlugin vue腳手架中集成插件 把官方資源

    2024年02月03日
    瀏覽(22)
  • 前后端 java 對接??低暠O(jiān)控-hls實現(xiàn)h5播放

    前后端 java 對接海康威視監(jiān)控-hls實現(xiàn)h5播放

    ??档墨@取監(jiān)控預(yù)覽流的接口當(dāng)中支持 rtsp、rtmp、hls等協(xié)議。 這篇文章主要是說hls協(xié)議的。 貼上??档拈_發(fā)平臺地址,其中有對應(yīng)的API:海康開發(fā)平臺 這里除了main方法之外,有兩個方法,分別是: 1)分頁獲取監(jiān)控點資源。 即返回所有的監(jiān)控點信息。 2)獲取監(jiān)控點預(yù)覽取

    2024年02月08日
    瀏覽(19)
  • web前端——HTML+CSS實現(xiàn)九宮格

    web前端——HTML+CSS實現(xiàn)九宮格

    web前端——HTML+CSS實現(xiàn)九宮格

    2024年02月05日
    瀏覽(20)
  • vue對接海康web1.5.2開發(fā)包,實現(xiàn)攝像頭畫面展示

    vue對接??祑eb1.5.2開發(fā)包,實現(xiàn)攝像頭畫面展示

    目錄 前言 一、首先下載視頻web插件v.1.5.2版本 二、利用官方插件包進行相關(guān)需求開發(fā) 1.官方插件包和開發(fā)文檔的下載 2.在項目中引入插件包的相關(guān)的js (1)下載完成后打開 (2)在項目中public文件下創(chuàng)建一個文件夾放視頻插件js 3..new 一個WebControl 插件相關(guān)實例 ?(1)創(chuàng)建Web

    2024年02月08日
    瀏覽(27)
  • vue2使用rtsp視頻流接入??低晹z像頭(純前端)

    vue2使用rtsp視頻流接入??低晹z像頭(純前端)

    ??低暪俜降腞TSP最新取流格式如下: rtsp://用戶名:密碼@IP:554/Streaming/Channels/101 用戶名和密碼 IP就是登陸攝像頭時候的IP(筆者這里IP是192.168.1.210) 所以筆者的rtsp流地址就是 rtsp://用戶名:密碼@192.168.1.210:554/Streaming/Channels/101 1.1關(guān)閉 螢石云的接入 1.2 調(diào)整視頻編碼為H.264 在此下載

    2024年04月26日
    瀏覽(25)
  • vue前端對接監(jiān)控視頻 FLV格式 (分屏的操作 單屏 ,四平 ,六屏)

    vue前端對接監(jiān)控視頻 FLV格式 (分屏的操作 單屏 ,四平 ,六屏)

    vue前端對接監(jiān)控視頻 FLV格式 提示:寫完文章后,目錄可以自動生成,如何生成可參考右邊的幫助文檔 接觸智慧園區(qū),智慧工地,水泵站等項目之后,發(fā)現(xiàn)都有實時監(jiān)控的對接,并且是可以多屏進行,就研究了相關(guān)的技術(shù)棧,找到了這個強大的播放器對前端還是很友好的,話

    2024年02月03日
    瀏覽(16)
  • 【vue2】前端如何播放rtsp 視頻流,拿到rtsp視頻流地址如何處理,??狄曨lrtsp h264 如何播放

    【vue2】前端如何播放rtsp 視頻流,拿到rtsp視頻流地址如何處理,??狄曨lrtsp h264 如何播放

    最近在寫vue2 項目其中有個需求是實時播放攝像頭的視頻,攝像頭是 ???的設(shè)備,搞了很長時間終于監(jiān)控視頻出來了,記錄一下,放置下次遇到。文章有點長,略顯啰嗦請耐心看完。 測試?測試什么?測試rtsp視頻流能不能播放。 video mediaplay官網(wǎng) 即(VLC) 下載、安裝完VLC后

    2024年02月05日
    瀏覽(25)
  • ???綜合安防管理平臺 對接

    海康 綜合安防管理平臺 對接

    1.1 官網(wǎng)介紹 1.2 個人理解 綜合安防管理平臺部署之后,有2個系統(tǒng),一個是綜合安防管理平臺:是用戶端系統(tǒng),一個是運營中心:是綜合安防平臺的后臺管理系統(tǒng),可提供api與業(yè)務(wù)平臺對接,實現(xiàn)實時預(yù)覽、錄播回放、語音對講、報警訂閱等功能。 1.3 綜合安防管理平臺 1.4 運

    2024年02月06日
    瀏覽(13)
  • FFMPEG+mediamtx 實現(xiàn)海康相機視頻播放

    FFMPEG+mediamtx 實現(xiàn)??迪鄼C視頻播放

    使用FFMPEG對海康相機視頻進行讀取,重新編碼后再進行推流,推到mediamtx,再通過網(wǎng)頁播放器或其他客戶端拉取視頻并播放 隨便找的一個安裝教程:https://blog.csdn.net/weixin_44704985/article/details/109532224 安裝后需配置到環(huán)境變量 https://github.com/bluenviron/mediamtx/releases 要是打不開自己

    2024年02月07日
    瀏覽(16)
  • ??禂z像頭web3.3前端實現(xiàn)

    ??禂z像頭web3.3前端實現(xiàn)

    ?上篇我發(fā)布了一篇文章,有一個刷新頁面攝像頭就消失的bug,這個代碼就是我改過以后得。 直接就放到組件里就行。要是不出來的話,可能是你們插件有問題??梢灾匦掳惭b一次插件。 template ? ? div class=\\\"chart-box\\\" ref=\\\"chartBox\\\" ? ? ? ? div class=\\\"chart-body\\\" ref=\\\"divPlugin\\\" id=\\\"divPlu

    2024年02月20日
    瀏覽(27)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包