实现网易云视频直播播放器功能

<!-- 直播播放器区域 -->
        <div class="live-channel-player-area">
            <video id="my-video" class="video-js" controls width="320">
                <source src="http://v1.live.126.net/live/4016cd4acc8041b69551cc4ce1696fce.flv" type='video/flv' />
                <source src="http://pullhls1.live.126.net/live/4016cd4acc8041b69551cc4ce1696fce/playlist.m3u8" type="application/x-mpegURL" />
            </video>
            <div class="logo">
                <img alt="" src="/resources/img/liveSupport/sylogo_01.png">
            </div>
            <a class="back" href="/liveSupport/index">
                <span class="reback"></span>
            </a>
        </div>
$(function(){
    var width = document.documentElement.clientWidth;
    var height = (width * 720) / 1280;
    var btnLeft = width / 2 - 90 / 2;
    var btnTop = height / 2 - 45 / 2;

    var myPlayer = neplayer("my-video", {
        width : width,
        height : height
    }, function() {
        $(".video-js .vjs-big-play-button").css({
            "left" : btnLeft + "px",
            "top" : btnTop + "px"
        })
    });
    myPlayer.onError(function(err) {
        if (err.errCode == 2) {
            $(".vjs-modal-dialog-content").html("网络原因导致无法观看");
        } else if (err.errCode == 3) {
            $(".vjs-modal-dialog-content").html("您的浏览器暂不支持本次直播的信号源");
        } else if (err.errCode == 4) {
            $(".vjs-modal-dialog-content").html("当前暂无直播信号");
        }
    });

    myPlayer.onPlayState(1, function() {
        console.log('play');
        $('.back').addClass('hide');
    });
    myPlayer.onPlayState(2, function() {
        console.log('pause');
        $('.back').removeClass('hide');
    });
    myPlayer.onPlayState(3, function() {
        console.log('ended');
        $('.back').removeClass('hide');
    });
});

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值