video.js使用改變ui

1 <video id="my_video" class="video-js vjs-default-skin vjs-big-play-centered my-vedio" preload="auto" controls width="800" height="600" align="middle" poster="image/vedio.png" data-setup="{}">
3      <source src="video/2.mp4" type="video/mp4" />
4      <!-- 加載hls視頻-->
5      <source src="http://live.hkstv.hk.lxdns.com/live/hks/playlist.m3u8" type="application/x-mpegURL">
6      <!-- 加載rtmp視頻-->
7      <source src="rtmp://live.hkstv.hk.lxdns.com/live/hks" type="rtmp/flv" />
8 </video>

poster屬性用於設置預覽圖javascript

source用於設置視頻地址css

獲取video中各類默認UIjava

 var myPlayer = videojs('my_video');
 var c = myPlayer.controlBar.children();
 console.log(c);

我只發現了一個比較蠢的辦法。數組

在console中能夠看到一個UI數組,選擇本身要改變的變量,好比我要刪除全屏圖標,從新添加全屏事件app

   myPlayer.controlBar.removeChild(c[15]);
    var SBtn = myPlayer.controlBar.addChild('button');
    SBtn.addClass('vjs-fullscreen-control');
    SBtn.add  //在自定義的全屏button中添加id屬性
    SBtn.setAttribute('id', 'fs');
    // 播放時處理的代碼
    myPlayer.on('play', function(event) {
        event.preventDefault();
        /* Act on the event */
        played = true;
        console.log('play');
        $("#md-video-title").hide();
    });
    // 中止時要處理的代碼
    myPlayer.on('pause', function(event) {
        event.preventDefault();
        /* Act on the event */
        played = false;
        console.log('play');
        $("#md-video-title").show();
    });

    $("#fs").on('click', function(event) {
        console.log("放大視頻");
        $('#myModal').modal('toggle')
        $("#hide-container").after($("#my_video"));
        $("#my_video").css({
            width: '1140',
            height: '600',
            'border-color':'#ffffff'
        });
        if (played) {
            myPlayer.play();
        }

    });
相關文章
相關標籤/搜索