现在在wordpress集成播放功能的越来越多,如果您也想做个这样的功能其实也是非常的简单,只需要按照以下步奏添加代码即可。
- add_shortcode(“ckplayer”,“ipc_ckplayer”);
- function ipc_ckplayer( $atts, $content=null )
- {
- return ‘<embed name=”Player” id=”Player” src=”‘.get_stylesheet_directory_uri().‘/ckplayer/ckplayer.swf” flashvars=”f=’.$content.‘&p=0″ quality=”high” width=”650″ height=”400″ align=”middle” allowScriptAccess=”always” allowFullscreen=”true” type=”application/x-shockwave-flash”></embed>’;
- }
添加到主题functions.php里面其中如果您用的是解析需要把上面f替换下,如灯哥解析需要修改为a。
上面的代码不支持移动端,如果需要支持移动端 ,请添加以下代码
- add_shortcode(“ckplayer”,“ipc_ckplayer”);
- function ipc_ckplayer( $atts, $content=null ) {
- $code=“<div id=’air’></div>
- <script type=’text/javascript’>
- var flashvars={
- f:’解析地址?参数=”.$url.“‘,
- s:2,
- c:0
- }
- var video=[‘xxxx->video/mp4’];
- CKobject.embed(‘ckplayer地址’,’air’,’ckplayer_air’,’100%’,’100%’,false,flashvars,video);
- </script>”;
- return $code;
宽高值自己设定 p=0为 不自动播放,
使用代码:
<embed name="Player" id="Player" src="https://www.xhsay.com/wp-content/themes/ruike/ckplayer/ckplayer.swf" flashvars="a=视频地址&p=0" quality="high" width="100%" height="500" align="middle" allowScriptAccess="always" allowFullscreen="true" type="application/x-shockwave-flash"></embed>