zoukankan      html  css  js  c++  java
  • vue 使用vue-video-player播放hls格式视频

    安装 

    vue-video-player   在 “
    devDependencies
    ” 中
    安装 
    videojs-contrib-hls 在“
    dependencies
    ”中
     
    main.js 中引入
    import hls from 'videojs-contrib-hls'
    import VideoPlayer from 'vue-video-player';
    import "video.js/dist/video-js.css"
    import "vue-video-player/src/custom-theme.css"
    
    Vue.use(hls)
    Vue.use(VideoPlayer)
     
    页面中使用 第一种方式
    <video id="my-video" class="video-js vjs-default-skin" controls preload="auto">
                <source src="http://ivi.bupt.edu.cn/hls/cctv1.m3u8" type="application/x-mpegURL" />
              </video>
    import "video.js/dist/video-js.css";
    import videojs from "video.js";
    import "videojs-contrib-hls";
    mounted(){
        videojs(
          "my-video",
          {
            bigPlayButton: false,
            textTrackDisplay: false,
            posterImage: true,
            errorDisplay: false,
            controlBar: true
          },
          function() {
            this.play();
          }
        );
    }

    页面中使用 第二种方式

    <video-player
                class="video-player vjs-custom-skin"
                :playsinline="true"
                :options="'http://ivi.bupt.edu.cn/hls/cctv1.m3u8'|videoOption">
              </video-player>
    import 'videojs-contrib-hls'
    filters:{
    videoOption(val) {
          console.log('val',val)
            return {
                live: false,
                preload: "auto",
                autoplay: true,
                language: "zh-CN",
                aspectRatio: "16:8",
                fluid: true,
                sources: [
                    {
                        src: val //url地址
                    }
                ],
                notSupportedMessage: "此视频暂无法播放,请稍后再试", //允许覆盖Video.js无法播放媒体源时显示的默认信息。
                controlBar: {
                    timeDivider: false,
                    durationDisplay: false,
                    remainingTimeDisplay: false,
                    fullscreenToggle: true //全屏按钮
                },
                flash: {
                    hls: {
                        withCredentials: false
                    }
                }
            }
        },
    }
     
     
  • 相关阅读:
    数组实现队列
    qsort用法 (转)
    枚举法
    HDU 2293
    bfs 街道赛跑
    漫谈二分查找Binary Search (转)
    qsort 结构体二级排序实例
    优化枚举法
    10项比较重要的.NET技术
    ADO.NET SQL Provider 和 ADO.NET OLE DB Provider 和 ADO.NET ODBC Provider 性能对比。
  • 原文地址:https://www.cnblogs.com/Byme/p/11419131.html
Copyright © 2011-2022 走看看