[苹果CMSV8教程]简单实现播放界面添加线路切换功能

2019-06-05 0 524

本文主要介绍苹果CMS简单实现播放界面添加线路切换的方法。
实现原理及方法:修改系统player.js,添加部分代码实现。
第一步:修改 /js/player.js:
在前面添加下面代码:

var intline=1;  //默认线路
var url_array=[
    "http://aikan-tv.com/?url=",
   "https://api.47ks.com/webcloud/?v=",
   "http://api.nohacks.cn/?url=",
   "http://api.baiyug.cn/vip/?url="
   ];
 //读缓存参数
 var myurl=localStorage.getItem("url_num"); 
 if( myurl!=null && myurl >0)  
  {
var jxurl=url_array[Number(myurl)-1];
  }else{ 
   jxurl=url_array[Number(intline)-1];
 }
//url_jump(0);
//alert(jxurl);
  function url_jump(flag){   //切换线路
if  ( flag <= url_array.length)  {
 localStorage.setItem("url_num", flag); 
window.location.href = window.location.href;
//alert("切换成功!");
     }
}

第二步:修改player目录下*.js,主要是用变量”jxurl”替换解析网址,js里需用 ‘+jxurl+’ 替换 解析网址。

以苹果CMS默认推荐的TV6资源解析包里的qq.js为例:

原代码为:

var uid = MacPlayer.PlayUrl;
if(uid.indexOf('http') > -1){
	//url
	MacPlayer.Html = '<iframe width="100%" height="'+MacPlayer.Height+'" src="http://api.30pan.com/api/?url='+uid+'" frameborder="0" border="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>';
	MacPlayer.Show();
}else{
	//id
	MacPlayer.Html = '<iframe width="100%" height="'+MacPlayer.Height+'" src="http://api.30pan.com/api/?url='+uid+'" frameborder="0" border="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>';
	MacPlayer.Show();</pre>
修改为:


<pre>var uid = MacPlayer.PlayUrl;
if(uid.indexOf('http') > -1){
	
	//url
	MacPlayer.Html = '<iframe width="100%" height="'+MacPlayer.Height+'" src="'+jxurl+''+uid+'" frameborder="0" border="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>';
	MacPlayer.Show();
}else{
	//id
	MacPlayer.Html = '<iframe width="100%" height="'+MacPlayer.Height+'" src="'+jxurl+''+uid+'" frameborder="0" border="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>';
	MacPlayer.Show();
}

用上面方法修改支持切换的视频站的js文件(letv,qq,mgtv,mp4,sohu,qiyi,youku,m3u8等)

第三步:添加到模块

代码 :

<a href="javascript:void(0)" rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  onclick="url_jump(1);">播放线路1</a>
<a href="javascript:void(0)" rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  onclick="url_jump(2);">播放线路2</a>
<a href="javascript:void(0)" rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  onclick="url_jump(3);">播放线路3</a>
<a href="javascript:void(0)" rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  onclick="url_jump(4);">播放线路4</a>

添加到模板 vod_play.html 里的合适位置,以默认模板为例,可以添加到下面的代码后面:

{maccms:head}
<div class="wrap">
<div class="money_all"><script type="text/javascript" language="javascript" src="{maccms:path_ads}all-top.js"></script></div>
<div class="b"><h6>当前位置:[vod:textlink]  [vod:playname]</h6></div>

保存上传,清除浏览器缓存,完成

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

抓虾网 经验教程 [苹果CMSV8教程]简单实现播放界面添加线路切换功能 https://www.zhuax.com/416.html

相关文章

官方客服团队

为您解决烦忧 - 24小时在线 专业服务