码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2016-08-26 12:14:49      阅读:1444      评论:0      收藏:0      [点我收藏+]

标签:

<!-- 直播播放器区域 -->
        <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‘);
    });
});

技术分享

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

标签:

原文地址:http://www.cnblogs.com/zhangwei595806165/p/5809737.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!