An example introduction to the development of online on-demand movie network ckplayer player on WeChat

高洛峰
Release: 2017-03-24 15:01:18
Original
10368 people have browsed it

We are about to start writing a small project in this lesson. This project is mainly about writing an online on-demand movie network. The player we use is ckplayer

Basic introduction to ckplayer:

# The full name of ##ckplayer is: super cool flv player. It is a software used to play videos on web pages. The supported formats are as follows:

An example introduction to the development of online on-demand movie network ckplayer player on WeChat

You need to make a video player yourself. The specific button positions and bottom background settings of the player style are set in ckplayer/ckplayer.js.

The current address can be downloaded from their official website, http://www.ckplayer.com/bbs/forum.php?mod=viewthread&tid=10864

Unzip the files inside Can:

An example introduction to the development of online on-demand movie network ckplayer player on WeChat

After opening, unzip it and open it in the environment. However, I found that there are a lot of things in it that affect the city appearance, so I just need to modify the index.htm file:

nbsp;html>


<meta>
<title>夺命雷公狗电影点播系统</title>
<style>
body,td,th {
    font-size: 14px;
    line-height: 26px;
}
body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
}
p {
    margin-top: 5px;
    margin-right: 0px;
    margin-bottom: 0px;
    margin-left: 0px;
    padding-left: 10px;
}
#a1{
    /*播放器大小的设置*/
    position:relative;
    z-index: 100;
    width:900px;
    height:600px;
    float: left;
}
</style>
<script></script>


<p></p>
<!--
上面一行是播放器所在的容器名称,如果只调用flash播放器,可以只用<p id="a1"></p>
-->
<script></script>
<script>
    //如果你不需要某项设置,可以直接删除,注意var flashvars的最后一个值后面不能有逗号
//    function loadedHandler(){
//        if(CKobject.getObjectById(&#39;ckplayer_a1&#39;).getType()){//说明使用html5播放器
//            alert(&#39;播放器已加载,调用的是HTML5播放模块&#39;);
//        }
//        else{
//            alert(&#39;播放器已加载,调用的是Flash播放模块&#39;);
//        }
//    }
    var _nn=0;
    function ckplayer_status(str){
        _nn+=1;
        if(_nn>100){
            _nn=0;
            document.getElementById(&#39;statusvalue&#39;).value=&#39;&#39;;
        }
        document.getElementById(&#39;statusvalue&#39;).value=str+&#39;\n&#39;+document.getElementById(&#39;statusvalue&#39;).value;
    }
    
    var flashvars={
        f:&#39;http://weixin.showtp.com/ckplayer/test.flv&#39;,//视频地址
        a:&#39;&#39;,//调用时的参数,只有当s>0的时候有效
        s:&#39;0&#39;,//调用方式,0=普通方法(f=视频地址),1=网址形式,2=xml形式,3=swf形式(s>0时f=网址,配合a来完成对地址的组装)
        c:&#39;0&#39;,//是否读取文本配置,0不是,1是
        x:&#39;&#39;,//调用配置文件路径,只有在c=1时使用。默认为空调用的是ckplayer.xml
        i:&#39;http://www.ckplayer.com/images/loadimg3.jpg&#39;,//初始图片地址
        d:&#39;http://www.ckplayer.com/down/pause6.1_1.swf|http://www.ckplayer.com/down/pause6.1_2.swf&#39;,//暂停时播放的广告,swf/图片,多个用竖线隔开,图片要加链接地址,没有的时候留空就行
        u:&#39;&#39;,//暂停时如果是图片的话,加个链接地址
        l:&#39;http://www.ckplayer.com/down/adv6.1_1.swf|http://www.ckplayer.com/down/adv6.1_2.swf&#39;,//前置广告,swf/图片/视频,多个用竖线隔开,图片和视频要加链接地址
        r:&#39;&#39;,//前置广告的链接地址,多个用竖线隔开,没有的留空
        t:&#39;10|10&#39;,//视频开始前播放swf/图片时的时间,多个用竖线隔开
        y:&#39;&#39;,//这里是使用网址形式调用广告地址时使用,前提是要设置l的值为空
        z:&#39;http://www.ckplayer.com/down/buffer.swf&#39;,//缓冲广告,只能放一个,swf格式
        e:&#39;3&#39;,//视频结束后的动作,0是调用js函数,1是循环播放,2是暂停播放并且不调用广告,3是调用视频推荐列表的插件,4是清除视频流并调用js功能和1差不多,5是暂停播放并且调用暂停广告
        v:&#39;80&#39;,//默认音量,0-100之间
        p:&#39;1&#39;,//视频默认0是暂停,1是播放,2是不加载视频
        h:&#39;0&#39;,//播放http视频流时采用何种拖动方法,=0不使用任意拖动,=1是使用按关键帧,=2是按时间点,=3是自动判断按什么(如果视频格式是.mp4就按关键帧,.flv就按关键时间),=4也是自动判断(只要包含字符mp4就按mp4来,只要包含字符flv就按flv来)
        q:&#39;&#39;,//视频流拖动时参考函数,默认是start
        m:&#39;&#39;,//让该参数为一个链接地址时,单击播放器将跳转到该地址
        o:&#39;&#39;,//当p=2时,可以设置视频的时间,单位,秒
        w:&#39;&#39;,//当p=2时,可以设置视频的总字节数
        g:&#39;&#39;,//视频直接g秒开始播放
        j:&#39;&#39;,//跳过片尾功能,j>0则从播放多少时间后跳到结束,<0则总总时间-该值的绝对值时跳到结束
        k:&#39;30|60&#39;,//提示点时间,如 30|60鼠标经过进度栏30秒,60秒会提示n指定的相应的文字
        n:&#39;这是提示点的功能,如果不需要删除k和n的值|提示点测试60秒&#39;,//提示点文字,跟k配合使用,如 提示点1|提示点2
        wh:&#39;&#39;,//宽高比,可以自己定义视频的宽高或宽高比如:wh:&#39;4:3&#39;,或wh:&#39;1080:720&#39;
        lv:&#39;0&#39;,//是否是直播流,=1则锁定进度栏
        loaded:&#39;loadedHandler&#39;,//当播放器加载完成后发送该js函数loaded
        //调用播放器的所有参数列表结束
        //以下为自定义的播放器参数用来在插件里引用的
        my_url:encodeURIComponent(window.location.href)//本页面地址
        //调用自定义播放器参数结束
        };
    var params={bgcolor:&#39;#FFF&#39;,allowFullScreen:true,allowScriptAccess:&#39;always&#39;};//这里定义播放器的其它参数如背景色(跟flashvars中的b不同),是否支持全屏,是否支持交互
    var video=[&#39;http://weixin.showtp.com/ckplayer/test.flv&#39;];
    CKobject.embed(&#39;ckplayer/ckplayer.swf&#39;,&#39;a1&#39;,&#39;ckplayer_a1&#39;,&#39;100%&#39;,&#39;100%&#39;,false,flashvars,video,params);
    /*
        以上代码演示的兼容flash和html5环境的。如果只调用flash播放器或只调用html5请看其它示例
    */
    function videoLoadJs(s){
        alert("执行了播放");
    }
    function playerstop(){
        //只有当调用视频播放器时设置e=0或4时会有效果
        alert(&#39;播放完成&#39;);    
    }
    var _nn=0;//用来计算实时监听的条数的,超过100条记录就要删除,不然会消耗内存
    
    function getstart(){
        var a=CKobject.getObjectById(&#39;ckplayer_a1&#39;).getStatus();
        var ss=&#39;&#39;;
        for (var k in a){
            ss+=k+":"+a[k]+&#39;\n&#39;;
        }
        alert(ss);
    }
    function ckadjump(){
        alert(&#39;这里演示了点击跳过广告按钮后的执行的动作,如果注册会员可以做成直接跳过的效果。&#39;);
    }
    //开关灯
    var box = new LightBox();
    function closelights(){//关灯
        box.Show();
        CKobject._K_(&#39;a1&#39;).style.width=&#39;940px&#39;;
        CKobject._K_(&#39;a1&#39;).style.height=&#39;550px&#39;;
        CKobject.getObjectById(&#39;ckplayer_a1&#39;).width=940;
        CKobject.getObjectById(&#39;ckplayer_a1&#39;).height=550;
    }
    function openlights(){//开灯
        box.Close();
        CKobject._K_(&#39;a1&#39;).style.width=&#39;600px&#39;;
        CKobject._K_(&#39;a1&#39;).style.height=&#39;400px&#39;;
        CKobject.getObjectById(&#39;ckplayer_a1&#39;).width=600;
        CKobject.getObjectById(&#39;ckplayer_a1&#39;).height=400;
    }
    function changePrompt(){
        CKobject.getObjectById(&#39;ckplayer_a1&#39;).promptUnload();//卸载掉目前的
        CKobject.getObjectById(&#39;ckplayer_a1&#39;).changeFlashvars(&#39;{k->10|20|30}{n->重设提示点一|重设提示点二|重设提示点三}&#39;);
        CKobject.getObjectById(&#39;ckplayer_a1&#39;).promptLoad();//重新加载
    }
    function addflash(){
        if(CKobject.Flash()[&#39;f&#39;]){
            CKobject._K_(&#39;a1&#39;).innerHTML=&#39;&#39;;
            CKobject.embedSWF(&#39;ckplayer/ckplayer.swf&#39;,&#39;a1&#39;,&#39;ckplayer_a1&#39;,&#39;600&#39;,&#39;400&#39;,flashvars,params);
        }
        else{
            alert(&#39;该环境中没有安装flash插件,无法切换&#39;);
        }
    }
    function addhtml5(){
        if(CKobject.isHTML5()){
            support=[&#39;all&#39;];
            CKobject._K_(&#39;a1&#39;).innerHTML=&#39;&#39;;
            CKobject.embedHTML5(&#39;a1&#39;,&#39;ckplayer_a1&#39;,600,400,video,flashvars,support);
        }
        else{
            alert(&#39;该环境不支持html5,无法切换&#39;);
        }
    }
    function addListener(){
        if(CKobject.getObjectById(&#39;ckplayer_a1&#39;).getType()){//说明使用html5播放器
            CKobject.getObjectById(&#39;ckplayer_a1&#39;).addListener(&#39;play&#39;,playHandler);
        }
        else{
            CKobject.getObjectById(&#39;ckplayer_a1&#39;).addListener(&#39;play&#39;,&#39;playHandler&#39;);
        }
    }
    function playHandler(){
        alert(&#39;因为注册了监听播放,所以弹出此内容,删除监听将不再弹出&#39;);
    }
    function removeListener(){//删除监听事件
        if(CKobject.getObjectById(&#39;ckplayer_a1&#39;).getType()){//说明使用html5播放器
            CKobject.getObjectById(&#39;ckplayer_a1&#39;).removeListener(&#39;play&#39;,playHandler);
        }
        else{
            CKobject.getObjectById(&#39;ckplayer_a1&#39;).removeListener(&#39;play&#39;,&#39;playHandler&#39;);
        }
    }
</script>

Copy after login
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>夺命雷公狗电影点播系统</title>
<style type="text/css">
body,td,th {
    font-size: 14px;
    line-height: 26px;
}
body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
}
p {
    margin-top: 5px;
    margin-right: 0px;
    margin-bottom: 0px;
    margin-left: 0px;
    padding-left: 10px;
}
#a1{
    /*播放器大小的设置*/
    position:relative;
    z-index: 100;
    width:900px;
    height:600px;
    float: left;
}
</style>
<script type="text/javascript" src="js/offlights.js"></script>
</head>

<body>
<div id="a1"></div>
<!--
上面一行是播放器所在的容器名称,如果只调用flash播放器,可以只用<div id="a1"></div>
-->
<script type="text/javascript" src="ckplayer/ckplayer.js" charset="utf-8"></script>
<script type="text/javascript">
    //如果你不需要某项设置,可以直接删除,注意var flashvars的最后一个值后面不能有逗号
//    function loadedHandler(){
//        if(CKobject.getObjectById(&#39;ckplayer_a1&#39;).getType()){//说明使用html5播放器
//            alert(&#39;播放器已加载,调用的是HTML5播放模块&#39;);
//        }
//        else{
//            alert(&#39;播放器已加载,调用的是Flash播放模块&#39;);
//        }
//    }
    var _nn=0;
    function ckplayer_status(str){
        _nn+=1;
        if(_nn>100){
            _nn=0;
            document.getElementById(&#39;statusvalue&#39;).value=&#39;&#39;;
        }
        document.getElementById(&#39;statusvalue&#39;).value=str+&#39;\n&#39;+document.getElementById(&#39;statusvalue&#39;).value;
    }
    
    var flashvars={
        f:&#39;http://weixin.showtp.com/ckplayer/test.flv&#39;,//视频地址
        a:&#39;&#39;,//调用时的参数,只有当s>0的时候有效
        s:&#39;0&#39;,//调用方式,0=普通方法(f=视频地址),1=网址形式,2=xml形式,3=swf形式(s>0时f=网址,配合a来完成对地址的组装)
        c:&#39;0&#39;,//是否读取文本配置,0不是,1是
        x:&#39;&#39;,//调用配置文件路径,只有在c=1时使用。默认为空调用的是ckplayer.xml
        i:&#39;http://www.ckplayer.com/images/loadimg3.jpg&#39;,//初始图片地址
        d:&#39;http://www.ckplayer.com/down/pause6.1_1.swf|http://www.ckplayer.com/down/pause6.1_2.swf&#39;,//暂停时播放的广告,swf/图片,多个用竖线隔开,图片要加链接地址,没有的时候留空就行
        u:&#39;&#39;,//暂停时如果是图片的话,加个链接地址
        l:&#39;http://www.ckplayer.com/down/adv6.1_1.swf|http://www.ckplayer.com/down/adv6.1_2.swf&#39;,//前置广告,swf/图片/视频,多个用竖线隔开,图片和视频要加链接地址
        r:&#39;&#39;,//前置广告的链接地址,多个用竖线隔开,没有的留空
        t:&#39;10|10&#39;,//视频开始前播放swf/图片时的时间,多个用竖线隔开
        y:&#39;&#39;,//这里是使用网址形式调用广告地址时使用,前提是要设置l的值为空
        z:&#39;http://www.ckplayer.com/down/buffer.swf&#39;,//缓冲广告,只能放一个,swf格式
        e:&#39;3&#39;,//视频结束后的动作,0是调用js函数,1是循环播放,2是暂停播放并且不调用广告,3是调用视频推荐列表的插件,4是清除视频流并调用js功能和1差不多,5是暂停播放并且调用暂停广告
        v:&#39;80&#39;,//默认音量,0-100之间
        p:&#39;1&#39;,//视频默认0是暂停,1是播放,2是不加载视频
        h:&#39;0&#39;,//播放http视频流时采用何种拖动方法,=0不使用任意拖动,=1是使用按关键帧,=2是按时间点,=3是自动判断按什么(如果视频格式是.mp4就按关键帧,.flv就按关键时间),=4也是自动判断(只要包含字符mp4就按mp4来,只要包含字符flv就按flv来)
        q:&#39;&#39;,//视频流拖动时参考函数,默认是start
        m:&#39;&#39;,//让该参数为一个链接地址时,单击播放器将跳转到该地址
        o:&#39;&#39;,//当p=2时,可以设置视频的时间,单位,秒
        w:&#39;&#39;,//当p=2时,可以设置视频的总字节数
        g:&#39;&#39;,//视频直接g秒开始播放
        j:&#39;&#39;,//跳过片尾功能,j>0则从播放多少时间后跳到结束,<0则总总时间-该值的绝对值时跳到结束
        k:&#39;30|60&#39;,//提示点时间,如 30|60鼠标经过进度栏30秒,60秒会提示n指定的相应的文字
        n:&#39;这是提示点的功能,如果不需要删除k和n的值|提示点测试60秒&#39;,//提示点文字,跟k配合使用,如 提示点1|提示点2
        wh:&#39;&#39;,//宽高比,可以自己定义视频的宽高或宽高比如:wh:&#39;4:3&#39;,或wh:&#39;1080:720&#39;
        lv:&#39;0&#39;,//是否是直播流,=1则锁定进度栏
        loaded:&#39;loadedHandler&#39;,//当播放器加载完成后发送该js函数loaded
        //调用播放器的所有参数列表结束
        //以下为自定义的播放器参数用来在插件里引用的
        my_url:encodeURIComponent(window.location.href)//本页面地址
        //调用自定义播放器参数结束
        };
    var params={bgcolor:&#39;#FFF&#39;,allowFullScreen:true,allowScriptAccess:&#39;always&#39;};//这里定义播放器的其它参数如背景色(跟flashvars中的b不同),是否支持全屏,是否支持交互
    var video=[&#39;http://weixin.showtp.com/ckplayer/test.flv&#39;];
    CKobject.embed(&#39;ckplayer/ckplayer.swf&#39;,&#39;a1&#39;,&#39;ckplayer_a1&#39;,&#39;100%&#39;,&#39;100%&#39;,false,flashvars,video,params);
    /*
        以上代码演示的兼容flash和html5环境的。如果只调用flash播放器或只调用html5请看其它示例
    */
    function videoLoadJs(s){
        alert("执行了播放");
    }
    function playerstop(){
        //只有当调用视频播放器时设置e=0或4时会有效果
        alert(&#39;播放完成&#39;);    
    }
    var _nn=0;//用来计算实时监听的条数的,超过100条记录就要删除,不然会消耗内存
    
    function getstart(){
        var a=CKobject.getObjectById(&#39;ckplayer_a1&#39;).getStatus();
        var ss=&#39;&#39;;
        for (var k in a){
            ss+=k+":"+a[k]+&#39;\n&#39;;
        }
        alert(ss);
    }
    function ckadjump(){
        alert(&#39;这里演示了点击跳过广告按钮后的执行的动作,如果注册会员可以做成直接跳过的效果。&#39;);
    }
    //开关灯
    var box = new LightBox();
    function closelights(){//关灯
        box.Show();
        CKobject._K_(&#39;a1&#39;).style.width=&#39;940px&#39;;
        CKobject._K_(&#39;a1&#39;).style.height=&#39;550px&#39;;
        CKobject.getObjectById(&#39;ckplayer_a1&#39;).width=940;
        CKobject.getObjectById(&#39;ckplayer_a1&#39;).height=550;
    }
    function openlights(){//开灯
        box.Close();
        CKobject._K_(&#39;a1&#39;).style.width=&#39;600px&#39;;
        CKobject._K_(&#39;a1&#39;).style.height=&#39;400px&#39;;
        CKobject.getObjectById(&#39;ckplayer_a1&#39;).width=600;
        CKobject.getObjectById(&#39;ckplayer_a1&#39;).height=400;
    }
    function changePrompt(){
        CKobject.getObjectById(&#39;ckplayer_a1&#39;).promptUnload();//卸载掉目前的
        CKobject.getObjectById(&#39;ckplayer_a1&#39;).changeFlashvars(&#39;{k->10|20|30}{n->重设提示点一|重设提示点二|重设提示点三}&#39;);
        CKobject.getObjectById(&#39;ckplayer_a1&#39;).promptLoad();//重新加载
    }
    function addflash(){
        if(CKobject.Flash()[&#39;f&#39;]){
            CKobject._K_(&#39;a1&#39;).innerHTML=&#39;&#39;;
            CKobject.embedSWF(&#39;ckplayer/ckplayer.swf&#39;,&#39;a1&#39;,&#39;ckplayer_a1&#39;,&#39;600&#39;,&#39;400&#39;,flashvars,params);
        }
        else{
            alert(&#39;该环境中没有安装flash插件,无法切换&#39;);
        }
    }
    function addhtml5(){
        if(CKobject.isHTML5()){
            support=[&#39;all&#39;];
            CKobject._K_(&#39;a1&#39;).innerHTML=&#39;&#39;;
            CKobject.embedHTML5(&#39;a1&#39;,&#39;ckplayer_a1&#39;,600,400,video,flashvars,support);
        }
        else{
            alert(&#39;该环境不支持html5,无法切换&#39;);
        }
    }
    function addListener(){
        if(CKobject.getObjectById(&#39;ckplayer_a1&#39;).getType()){//说明使用html5播放器
            CKobject.getObjectById(&#39;ckplayer_a1&#39;).addListener(&#39;play&#39;,playHandler);
        }
        else{
            CKobject.getObjectById(&#39;ckplayer_a1&#39;).addListener(&#39;play&#39;,&#39;playHandler&#39;);
        }
    }
    function playHandler(){
        alert(&#39;因为注册了监听播放,所以弹出此内容,删除监听将不再弹出&#39;);
    }
    function removeListener(){//删除监听事件
        if(CKobject.getObjectById(&#39;ckplayer_a1&#39;).getType()){//说明使用html5播放器
            CKobject.getObjectById(&#39;ckplayer_a1&#39;).removeListener(&#39;play&#39;,playHandler);
        }
        else{
            CKobject.getObjectById(&#39;ckplayer_a1&#39;).removeListener(&#39;play&#39;,&#39;playHandler&#39;);
        }
    }
</script>
</body>
</html>
Copy after login


The effect is as follows:

An example introduction to the development of online on-demand movie network ckplayer player on WeChat

Warm reminder, There are two places where you need to fill in the

of the playback address.

The above is the detailed content of An example introduction to the development of online on-demand movie network ckplayer player on WeChat. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!