LiveGBS GB28181國標(biāo)流媒體服務(wù)livePlayer 在vue中使用 且控制攝像頭

livePlayer的說明文檔:
https://www.liveqing.com/docs/manuals/LivePlayer.html#%E4%BA%8B%E4%BB%B6-event
1、安裝:

   npm install @liveqing/liveplayer
   npm i -D copy-webpack-plugin 

2扭粱、引入:
在webpack.dev.conf.js / vue.config.js文件下plugins中聲明插件new CopyWebpackPlugin引入和聲明插件:

const CopyWebpackPlugin = require('copy-webpack-plugin')

......
plugins: [
  new CopyWebpackPlugin([
     { from: 'node_modules/@liveqing/liveplayer/dist/component/crossdomain.xml'},
     { from: 'node_modules/@liveqing/liveplayer/dist/component/liveplayer.swf'},
     { from: 'node_modules/@liveqing/liveplayer/dist/component/liveplayer-lib.min.js', to: 'js/'}
  ])]
......

3舵鳞、在index.html中引入:

  <script type="text/javascript" src="./js/liveplayer-lib.min.js"></script>
 <!-- 直接復(fù)制 放在<head>標(biāo)簽里面  沒寫會報(bào)錯  videojs is not defined  -->

4、使用:

  <template>
    <div class="video-container" >
        <div  class="videoPlay">
          <live-player
            class="video"
            ref="player"
            :videoUrl="videoUrl"
            v-loading="loading"
            fluent
            autoplay
            live
            stretch></live-player>
        </div>
        <div class="videoControl" id="video_dialog">
            <div class="video_button">
                <el-button type="primary" @click="play(players)" >播放</el-button>
                <el-button type="primary" @click="stop()">暫停</el-button>
            </div>
            <div class="video_button" >
                <el-button  type="primary" @click="ptzControl('zoomin')">放大</el-button>
                <el-button  type="primary" @click="ptzControl('zoomout')">縮小</el-button>
            </div>
            <div class="video_button" >
                <el-button type="primary"  @click="ptzControl('left')"> 左</el-button>
                <el-button type="primary"  @click="ptzControl('up')">上</el-button>
                <el-button type="primary"  @click="ptzControl('right')"> 右</el-button>
                <el-button type="primary"  @click="ptzControl('down')">下</el-button>
            </div>
        </div>
    </div>
</template>

<script>
import LivePlayer from '@liveqing/liveplayer'
//需要用到的接口
import {Login,getChannelList,streamStart,controlPtz,streamStop} from '../plugins/request'
export default {
    data() {
        return {
            camidList: [],
            players: [],
            token: '',
            code: '',
            serial: '',
            command: '',
            streamID: '',
            videoUrl: '',
            loading: false
        }
    },
    components: {
        LivePlayer
    },
    mounted() {
        this.getChannels()
    },
    methods: {
        getChannels() {
            // 接口需要token  調(diào)用登錄接口獲取token
            this.loading = true
            const parmas = {
                'username': '',
                'password': ''
            }
            Login(parmas.username,parmas.password).then(res => {
                this.token = res.data.URLToken
                 getChannelList(this.token,'true').then(res => {
                    this.players = res.data.ChannelList
                    this.shuld(this.players[0])
                })
            })
        },
        shuld(data) {
            this.serial = data.DeviceID
            this.code = data.ID
            this.play()
        },
        play() {
            this.loading = true
            streamStart(this.serial,this.code,this.token).then(res => {
                this.videoUrl = res.data.FLV || ''
                this.streamID = res.data.StreamID
                this.loading = false
            })
        },
        ptzControl(command) {
           controlPtz(this.serial,this.code,command,this.token).then(res => {
                console.log(res)
                window.setTimeout(() => {
                    this.ptzStop()
                 }, 100)
            }  )
        },
        ptzStop() {
            controlPtz(this.serial,this.code,'stop',this.token).then(res => {
                console.log(res)
            })
        },
        stop() {
            streamStop(this.serial,this.code,this.token).then(res => {
                console.log(res)
            })
        }
    }
}
</script>

<style>
    .video-container {
        display: flex;
        flex-flow: row nowrap;
    }
    .video {
        width: 100%;
    }
    .videoControl {
        width: 30%;
    }
    .video_button {
        margin-top: 20px;
        margin-left: 30px;
    }
    .videoPlay {
        width: 60%;
    }
</style>

效果:


image.png
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末焊刹,一起剝皮案震驚了整個濱河市系任,隨后出現(xiàn)的幾起案子恳蹲,更是在濱河造成了極大的恐慌虐块,老刑警劉巖,帶你破解...
    沈念sama閱讀 221,273評論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件嘉蕾,死亡現(xiàn)場離奇詭異贺奠,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)错忱,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,349評論 3 398
  • 文/潘曉璐 我一進(jìn)店門儡率,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人以清,你說我怎么就攤上這事儿普。” “怎么了掷倔?”我有些...
    開封第一講書人閱讀 167,709評論 0 360
  • 文/不壞的土叔 我叫張陵眉孩,是天一觀的道長。 經(jīng)常有香客問我勒葱,道長浪汪,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 59,520評論 1 296
  • 正文 為了忘掉前任凛虽,我火速辦了婚禮死遭,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘凯旋。我一直安慰自己呀潭,他們只是感情好钉迷,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,515評論 6 397
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著钠署,像睡著了一般篷牌。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上踏幻,一...
    開封第一講書人閱讀 52,158評論 1 308
  • 那天枷颊,我揣著相機(jī)與錄音,去河邊找鬼该面。 笑死夭苗,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的隔缀。 我是一名探鬼主播题造,決...
    沈念sama閱讀 40,755評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼猾瘸!你這毒婦竟也來了界赔?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,660評論 0 276
  • 序言:老撾萬榮一對情侶失蹤牵触,失蹤者是張志新(化名)和其女友劉穎淮悼,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體揽思,經(jīng)...
    沈念sama閱讀 46,203評論 1 319
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡袜腥,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,287評論 3 340
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了钉汗。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片羹令。...
    茶點(diǎn)故事閱讀 40,427評論 1 352
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖损痰,靈堂內(nèi)的尸體忽然破棺而出福侈,到底是詐尸還是另有隱情,我是刑警寧澤卢未,帶...
    沈念sama閱讀 36,122評論 5 349
  • 正文 年R本政府宣布肪凛,位于F島的核電站,受9級特大地震影響尝丐,放射性物質(zhì)發(fā)生泄漏显拜。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,801評論 3 333
  • 文/蒙蒙 一爹袁、第九天 我趴在偏房一處隱蔽的房頂上張望远荠。 院中可真熱鬧,春花似錦失息、人聲如沸譬淳。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,272評論 0 23
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽邻梆。三九已至守伸,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間浦妄,已是汗流浹背尼摹。 一陣腳步聲響...
    開封第一講書人閱讀 33,393評論 1 272
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留剂娄,地道東北人蠢涝。 一個月前我還...
    沈念sama閱讀 48,808評論 3 376
  • 正文 我出身青樓,卻偏偏與公主長得像阅懦,于是被迫代替她去往敵國和親和二。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,440評論 2 359