wordpress文章(整合)插入自定义视频播放器 CKplayer CMP letv youku

2016年08月13日更新ckplayer,兼容手机播放;之前的调用仅支持pc播放。

// cplayer视频  
 
function cplayer_video($atts, $content=null){
 
	$randomid = 'player_'.random(3);
 
    // return '<p style="text-align: center;"><embed src=http://assets.iganlei.cn/player/k/player.swf?'.$content.'&isPlayerAd=0&autoplay=0 quality="high" width="610″ height="460″ align="middle" wmode="transparent" allowfullscreen="true" allowScriptAccess="never" allowNetworking="internal" type="application/x-shockwave-flash"/></p>';  
    return '<div id="'.$randomid.'" style="width:100%;min-height:500px"></div>
<script type="text/javascript" src="http://assets.iganlei.cn/player/k/player.js" charset="utf-8"></script>
<script type="text/javascript">'."
	var flashvars={
	    f:'".$content."',
	    c:0
	};
	var params={bgcolor:'#FFF',allowFullScreen:true,allowScriptAccess:'always',wmode:'transparent'};
	var video=['".$content."->video/mp4'];
	CKobject.embed('http://assets.iganlei.cn/player/k/player.swf','".$randomid."','ckplayer_".$randomid."','100%','500',false,flashvars,video,params);
</script>";
 
}  
 
 
/**
* 产生随机码
* @param $length - 要多长
* @param $numberic - 数字还是字符串
* @return 返回字符串
*/
function random($length, $numeric = 0) {
        PHP_VERSION < '4.2.0' && mt_srand((double)microtime() * 1000000);
        if($numeric) {
                $hash = sprintf('%0'.$length.'d', mt_rand(0, pow(10, $length) - 1));
        } else {
                $hash = '';
                $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
                $max = strlen($chars) - 1;
                for($i = 0; $i < $length; $i++) {
                        $hash .= $chars[mt_rand(0, $max)];
                }
        }
        return $hash;
}

random() 取自discuz

手机效果截图:

834374500948046874

或者微信扫一扫看效果:

1471061067

——————–以下为旧内容————————

在wordpress中插入自定义视频播放器,选了两款开源播放器,引用了优酷和乐视的无广告播放器。

只需要在主题对应的functions.php里面加几个函数就行了。

编辑器上会多了几个button,下图所示

20131129233318

将functions.php里的

  1. //全部结束  
  2. ?>  

替换成下面内容即可(如果是原主题 ,只需添加几个函数即可)

 
 
// 优酷视频  
 
function youku_video($atts, $content=null){  
 
    return '<p style="text-align: center;"><embed src=http://static.youku.com/v1.0.0223/v/swf/loader.swf?VideoIDS='.$content.'ID&winType=adshow quality="high" width="610″ height="460″ align="middle" wmode="transparent" allowfullscreen="true" allowScriptAccess="never" allowNetworking="internal" autostart="1″ type="application/x-shockwave-flash"/></p>';  
 
}  
 
// cmplayer视频  
 
function cmplayer_video($atts, $content=null){  
 
    // return '<p style="text-align: center;"><embed src=http://girls.iganlei.cn/player/cm/local_pn.swf?'.$content.'  width="610″ height="460″ align="middle" wmode="transparent" allowfullscreen="true" allowScriptAccess="never" allowNetworking="internal" autostart="0″ type="application/x-shockwave-flash"/></p>';  
    return '<p style="text-align: center;"><embed src=http://girls.iganlei.cn/player/cm/local_pn.swf?'.$content.'  width="610″ height="460″ align="middle" wmode="transparent" allowfullscreen="true" allowScriptAccess="never" allowNetworking="internal" autostart="0″ type="application/x-shockwave-flash"/></p>';  
 
}  
 
// letv视频  
 
function letv_video($atts, $content=null){  
 
    return '<p style="text-align: center;"><embed src=http://girls.iganlei.cn/get/player/LetvPlayer-austgl.swf?id='.$content.'&isPlayerAd=0&autoplay=0 quality="high" width="610″ height="460″ align="middle" wmode="transparent" allowfullscreen="true" allowScriptAccess="never" allowNetworking="internal" type="application/x-shockwave-flash"/></p>';  
 
}  
 
// cplayer视频  
 
function cplayer_video($atts, $content=null){
 
	$randomid = 'player_'.random(3);
 
     return '<p style="text-align: center;"><embed src=http://assets.iganlei.cn/player/k/player.swf?'.$content.'&isPlayerAd=0&autoplay=0 quality="high" width="610″ height="460″ align="middle" wmode="transparent" allowfullscreen="true" allowScriptAccess="never" allowNetworking="internal" type="application/x-shockwave-flash"/></p>';  
 
}  
 
add_shortcode('youku','youku_video');
 
add_shortcode('cmplayer','cmplayer_video');  
 
add_shortcode('letv','letv_video');  
 
add_shortcode('cplayer','cplayer_video');  
 
//添加HTML编辑器自定义快捷标签按钮
function appthemes_add_quicktags() {
?><script type="text/javascript">// < ![CDATA[ 
QTags.addButton( 'downs', '下载按钮', '<div class="article-social"><a href="','" target=_blank title="文件下载"  class="action action-popover actived" rel=nofollow><i class="glyphicon glyphicon-download-alt"></i>下载</a>' );
// ]]></script>< ?php } add_action('admin_print_footer_scripts', 'appthemes_add_quicktags' );
 
// 编辑器按钮  
 
add_action('after_wp_tiny_mce', 'bolo_after_wp_tiny_mce');  
 
function bolo_after_wp_tiny_mce($mce_settings) {  
 
?>  
 
<script type="text/javascript">  
 
 
QTags.addButton( 'youku', '优酷', "[youku]视频ID[/youku]" );//请将左边的{替换成[  
 
QTags.addButton( 'letv', 'letv', "[letv]视频ID[/letv]" );//请将左边的{替换成[  
 
QTags.addButton( 'cmplayer', 'cmplayer视频', "[cmplayer]flashvars[/cmplayer]" );//请将左边的{替换成[  
 
QTags.addButton( 'cplayer', 'cplayer视频', "[cplayer]flashvars[/cplayer]" );//请将左边的{替换成[  
 
function bolo_QTnextpage_arg1() {  
 
}  
 
</script>  
 
< ?php }  
 
//全部结束  
 
?>

插入优酷的

插入乐视的

cmp(这比起播放器作者的7k插件要精简吧,就一个函数调用)

ck

functions.php百度网盘下载(提取密码: ak27)

下载

未经允许不得转载:ganlei的个人博客 » wordpress文章(整合)插入自定义视频播放器 CKplayer CMP letv youku

赞 (4)
分享到:更多 ()