最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue實(shí)現(xiàn)flv格式視頻播放效果

 更新時(shí)間:2023年07月28日 15:58:45   作者:浮橋  
這篇文章主要介紹了vue實(shí)現(xiàn)flv格式視頻播放,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

公司項(xiàng)目需要實(shí)現(xiàn)攝像頭實(shí)時(shí)視頻播放,flv格式的視頻。先百度使用flv.js插件實(shí)現(xiàn),但是兩個(gè)攝像頭一個(gè)能放一個(gè)不能放,沒有找到原因。(開始兩個(gè)都能放,后端更改地址后不有一個(gè)不能放)但是在另一個(gè)系統(tǒng)上是可以播放的。使用的是jessibuca.js

jessibuca.js實(shí)現(xiàn)視頻播放

1、下載jessibuca.js包

這三個(gè)文件需要直接放到public文件夾里,不能在添加文件夾放置。

2、創(chuàng)建VideoPlayer.vue文件

<template>
    <div id="container" ref="container"></div>
</template>
<script>
export default {
    name: 'DemoPlayer',
    props: {
        videoUrl: {
            type: String,
            default: ''
        }
    },
    data() {
        return {
            jessibuca: null,
            version: '',
            wasm: false,
            vc: 'ff',
            playing: false,
            quieting: true,
            loaded: false, // mute
            showOperateBtns: false,
            showBandwidth: false,
            err: '',
            speed: 0,
            performance: '',
            volume: 1,
            rotate: 0,
            useWCS: false,
            useMSE: true,
            useOffscreen: false,
            recording: false,
            recordType: 'webm',
            scale: 0
        }
    },
    mounted() {
        this.create()
        window.onerror = (msg) => (this.err = msg)
    },
    unmounted() {
        this.jessibuca.destroy()
    },
    methods: {
        create(options) {
            options = options || {}
            this.jessibuca = new window.Jessibuca(
                Object.assign(
                    {
                        container: this.$refs.container,
                        videoBuffer: 0.2, // Number(this.$refs.buffer.value), // 緩存時(shí)長
                        isResize: false,
                        useWCS: this.useWCS,
                        useMSE: this.useMSE,
                        text: '',
                        // background: "bg.jpg",
                        loadingText: '瘋狂加載中...',
                        // hasAudio:false,
                        debug: true,
                        supportDblclickFullscreen: true,
                        showBandwidth: this.showBandwidth, // 顯示網(wǎng)速
                        operateBtns: {
                            fullscreen: this.showOperateBtns,
                            screenshot: this.showOperateBtns,
                            play: this.showOperateBtns,
                            audio: this.showOperateBtns
                        },
                        vod: this.vod,
                        forceNoOffscreen: !this.useOffscreen,
                        isNotMute: true,
                        timeout: 10
                    },
                    options
                )
            )
            var _this = this
            this.jessibuca.on('pause', function () {
                console.log('on pause')
                _this.playing = false
            })
            this.jessibuca.on('play', function () {
                console.log('on play')
                _this.playing = true
            })
            this.jessibuca.on('mute', function (msg) {
                console.log('on mute', msg)
                _this.quieting = msg
            })
            this.jessibuca.on('error', function (error) {
                console.log('error', error)
            })
            this.jessibuca.on('performance', function (performance) {
                var show = '卡頓'
                if (performance === 2) {
                    show = '非常流暢'
                } else if (performance === 1) {
                    show = '流暢'
                }
                _this.performance = show
            })
            this.jessibuca.on('play', () => {
                this.playing = true
                this.loaded = true
                this.quieting = this.jessibuca.isMute()
            })
        },
        play(videoUrl) {
            if (videoUrl) {
                this.jessibuca.play(videoUrl)
            } else {
                // this.$message.error('播放地址出錯(cuò)')
                this.destroy()
            }
        },
        mute() {
            this.jessibuca.mute()
        },
        cancelMute() {
            this.jessibuca.cancelMute()
        },
        pause() {
            this.jessibuca.pause()
            this.playing = false
            this.err = ''
            this.performance = ''
        },
        destroy() {
            if (this.jessibuca) {
                this.jessibuca.destroy()
            }
            this.create()
            this.playing = false
            this.loaded = false
            this.performance = ''
        }
    }
}
</script>
<style>
#container {
    background: rgba(13, 14, 27, 0.7);
    width: 100%;
    height: 100%;
}
</style>

3、使用組件

引入

import VideoPlayer from '@/components/VideoPlayer.vue'

使用

<VideoPlayer ref="VideoPlayer"></VideoPlayer>

播放

let url = 'http://182.150.58.94:15280/rtp/44010200492000000001_34020000001320000110.flv'
this.$refs.VideoPlayer.play(url)

效果

參考文檔:

jessibuca-api-文檔

參考官方實(shí)例 jessibuca-vue-demo

vue中播放flv流視頻

1、安裝環(huán)境npm install video.jsnpm install flv.js

2、引入video,在main.js中引入

import videojs from "video.js";
import "video.js/dist/video-js.css";
Vue.prototype.$video = videojs;

在這里插入圖片描述

3、在播放flv流視頻代碼如下

<template>
  <div class="wrapper">
    <video id="videoElement" controls autoplay muted width="800px" height="600px">
    </video>
    <button @click="play">播放</button>
  </div>
</template>
<script>
  import flvjs from "flv.js";
  export default {
    data() {
      return {
        player: null,
      }
    },
    mounted() {
        if (flvjs.isSupported()) {
          var videoElement = document.getElementById('videoElement');
          this.flvPlayer = flvjs.createPlayer({
            type: 'flv',
        isLive: true,
        hasAudio: false,
            url: 'http://192.168.1.212/hdl/hlsram/live1.flv'
          });
          this.flvPlayer.attachMediaElement(videoElement);
          this.flvPlayer.load();
      	  this.flvPlayer.play();
        }
    },
    methods: {
      play() {
        this.flvPlayer.play();
      }
    },
    beforeDestroy() {
      // 播放器存在清除播放器
      if (this.player) {
         this.player.destroy()
       }
    }
  }
</script>
<style scoped>
  .wrapper {
    width: 800px;
    height: 600px;
    margin: 100px 30px;
    overflow: hidden;
    position: relative;
  }
  .iframe {
    width: 1024px;
    height: 608px;
    position: absolute;
    top: -150px;
    left: -120px;
  }
</style>

效果圖,本身電腦的原因存在延遲比較高

在這里插入圖片描述

到此這篇關(guān)于vue實(shí)現(xiàn)flv格式視頻播放的文章就介紹到這了,更多相關(guān)vue視頻播放內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • vue多次打包后出現(xiàn)瀏覽器緩存的問題及解決

    vue多次打包后出現(xiàn)瀏覽器緩存的問題及解決

    這篇文章主要介紹了vue多次打包后出現(xiàn)瀏覽器緩存的問題及解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-08-08
  • Vue.js表單控件實(shí)踐

    Vue.js表單控件實(shí)踐

    這篇文章主要為大家詳細(xì)介紹了Vue.js表單控件實(shí)踐,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-10-10
  • vue項(xiàng)目開啟gzip壓縮功能簡(jiǎn)單實(shí)例

    vue項(xiàng)目開啟gzip壓縮功能簡(jiǎn)單實(shí)例

    這篇文章主要給大家介紹了關(guān)于vue項(xiàng)目開啟gzip壓縮功能的相關(guān)資料,gizp壓縮是一種http請(qǐng)求優(yōu)化方式,通過減少文件體積來提高加載速度,文中通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2023-07-07
  • Vue3 style CSS 變量注入的實(shí)現(xiàn)

    Vue3 style CSS 變量注入的實(shí)現(xiàn)

    本文主要介紹了Vue3 style CSS 變量注入的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-07-07
  • Vue?插槽?Slots源碼解析與用法詳解

    Vue?插槽?Slots源碼解析與用法詳解

    這篇文章主要介紹了Vue?插槽?(Slots)?源碼解析與用法,通過實(shí)例,我們?nèi)媪私饬四J(rèn)插槽、具名插槽和作用域插槽的用法,并深入理解了其在Vue源碼中的實(shí)現(xiàn)原理,需要的朋友可以參考下
    2024-01-01
  • 解決Vue的文本編輯器 vue-quill-editor 小圖標(biāo)樣式排布錯(cuò)亂問題

    解決Vue的文本編輯器 vue-quill-editor 小圖標(biāo)樣式排布錯(cuò)亂問題

    這篇文章主要介紹了解決Vue的文本編輯器 vue-quill-editor 小圖標(biāo)樣式排布錯(cuò)亂問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2020-08-08
  • vue修改滾動(dòng)條樣式的方法

    vue修改滾動(dòng)條樣式的方法

    這篇文章主要介紹了vue修改滾動(dòng)條樣式,首先要知道,修改滾動(dòng)條樣式,利用偽元素-webkit-scrollbar。下面來看看文章內(nèi)容的具體實(shí)現(xiàn)吧
    2021-11-11
  • 淺談在不使用ssr的情況下解決Vue單頁面SEO問題(2)

    淺談在不使用ssr的情況下解決Vue單頁面SEO問題(2)

    這篇文章主要介紹了淺談在不使用ssr的情況下解決Vue單頁面SEO問題(2),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-11-11
  • Vue CLI3 開啟gzip壓縮文件的方式

    Vue CLI3 開啟gzip壓縮文件的方式

    gizp壓縮是一種http請(qǐng)求優(yōu)化方式,通過減少文件體積來提高加載速度。這篇文章主要介紹了Vue CLI3 開啟gzip壓縮,需要的朋友可以參考下
    2018-09-09
  • vue2中引用及使用 better-scroll的方法詳解

    vue2中引用及使用 better-scroll的方法詳解

    這篇文章主要介紹了vue2中引用better-scroll和使用 better-scroll的方法,使用時(shí)有三個(gè)要點(diǎn)及注意事項(xiàng)在文中給大家詳細(xì)介紹 ,需要的朋友可以參考下
    2018-11-11

最新評(píng)論

林口县| 安溪县| 电白县| 城市| 酒泉市| 钟祥市| 城口县| 大新县| 临泉县| 连江县| 青岛市| 子长县| 库车县| 河北省| 海林市| 特克斯县| 武功县| 察哈| 太谷县| 崇阳县| 乳山市| 鸡西市| 新巴尔虎右旗| 元朗区| 河津市| 东兰县| 中方县| 渑池县| 无棣县| 富裕县| 白山市| 德惠市| 中方县| 泽普县| 大庆市| 林周县| 睢宁县| 皮山县| 汾西县| 柞水县| 广饶县|