index2.js
12.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
/**
* Created by webshow on 2018/3/16.
*/
$(function () {
var language = (navigator.browserLanguage || navigator.language).toLowerCase();
if(language.indexOf('zh')>-1){
lang=2
}else if(language.indexOf('en')>-1){
lang=1
$('.inp').attr("placeholder","Chat with her…")
}else{
lang=2
}
key='dzxj4c';
console.log(returnCitySN["cname"])
var ua = navigator.userAgent.toLowerCase();
if (/android/.test(ua)) {
province =['北京','天津','河北','山西','内蒙古','辽宁','吉林','黑龙江','上海','江苏','浙江','安徽','福建','江西','山东 ','河南','湖北','湖南','广东','广西','海南 ','重庆','四川','贵州','云南','西藏','陕西','甘肃','青海','宁夏','新疆','香港','澳门']
for(var i=0;i<province.length;i++){
if(returnCitySN["cname"].indexOf(province[i])!=-1){
key="dzxj4c";
}
}
}
else if(/iphone|ipad|ipod/.test(ua)){
key='dzxj4c';
}
// var $ip = "http://ceshi.yabolive.tv/web";
var $ip = "https://webserver.yabolive.net";
var bilibi=true;
var bbb = location.href;
var data = url_get_params(bbb)
var userId = data.uid; //t
//sessionStorage.kkk = data.token;//k
function url_get_params(url_path) {
var url = url_path;
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.substr(url.indexOf("?") + 1);
strs = str.split("&");
for (var i = 0; i < strs.length; i++) {
theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
}
}
return theRequest;
}
var h=$(window).height()+80;
$(".video-play").css("height",h+'px');
//获取主播相关列表
room(userId)
$.ajax({
url: $ip + "/share/getHotList.html",
type: "post",
data: {
//'type':1,
'os':"WEB",
'cid':"web_gw",
'lang':2,
},
error: function (msg) {
console.log('请求出错');
},
success: function (msg) {
var data=JSON.parse(msg);
console.log(data);
var html=[];
for(var i=0;i<data.rooms.length;i++){
html+='<li><img src=https://zhibocdn.yabolive.net/comm'+data.rooms[i].faceimg+'?x-oss-process=image/resize,w_200><div class="live"><span class="dian"></span><span class="live-text">Live</span></div><i style="float: left;font-size: 0">'+data.rooms[i].roomId+'</i></li>';
}
$(".more-ul").html(html);
var id=data.rooms[0].roomId;
$(".more-ul li").on("click", function () {
var oid=$(this).children("i").text();
console.log(oid)
$(".video-play-bg1").addClass('video-play-bg').removeClass('video-play-bg1');
room(oid);
$("html,body").animate({scrollTop:0}, 0);
})
}
})
//闪灯
var t1=setInterval(function () {
if(bilibi==true){
$(".dian").fadeOut(200);
bilibi=false;
}else if(bilibi==false){
bilibi=true;
$(".dian").fadeIn(200);
}
},700)
$(window).on("scroll", function () {
if($(window).scrollTop() >= 50){
$(".down").fadeOut(0)
$(".down-bottom").fadeIn(200)
}
else if($(window).scrollTop() < 50){
$(".down").fadeIn(0)
$(".down-bottom").fadeOut(0)
}
})
//点击下载
$(".down-btn").on("click", function () {
browserRedirect();
})
$(".gift").on("click", function () {
browserRedirect();
})
$(".inp").on("click", function () {
browserRedirect();
})
$(".down-btn").on("click", function () {
browserRedirect();
})
$(".guanzhu").on("click", function () {
browserRedirect();
})
$(".text2").on("click", function () {
browserRedirect();
})
function room(o){
//获取直播间相关数据
$.ajax({
url: $ip + "/share/getInfo.html",
type: "post",
data: {
'uid':0,
'os': "WEB",
'cid': "web_gw",
'lang': 2,
'fid': o,
},
error: function (msg) {
console.log('请求出错');
},
success: function (msg) {
var data=JSON.parse(msg);
console.log(data);
if(data.code==1){
$(".play-btn").fadeIn(500);
var html=[];
html+='<div class="box-img">' +
'<img class="bg-img" src=https://zhibocdn.yabolive.net/comm'+data.room.faceImg+' alt="">' +
'</div>';
$(".video-play-bg").html(html)
var html2=[];
html2+='<img src=https://zhibocdn.yabolive.net/comm'+data.room.faceImg+'?x-oss-process=image/resize,w_50 alt="">'
html2+='<span class="name">'+data.room.roomName+'</span>'
if(lang==1) html2+='<span class="hot">'+data.room.lookNum+' 围观</span>'
else html2+='<span class="hot">'+data.room.lookNum+' Viewers</span>'
$(".more").html(html2);
//var vplay=data.room.hlsUrl;
$(".play-btn").unbind();
if(data.room.roomType == 3){
var html2 = [];
html2+='<video id="videoID" class="video-js vjs-big-play-centered " controls="true" preload="auto" controlsList="nofullscreen" webkit-playsinline="true" playsinline="true" style="width:10rem;height:92%; object-fit:fill;position: absolute;z-index: 10" poster=https://zhibocdn.yabolive.net/comm'+data.room.faceImg+'></video>';
$(".video-play-bg").html(html2);
$("video").on("contextmenu",function(){return false;});
var src = data.room.playUrl;
var Player=videojs("videoID",{
nativeControlsForTouch: false,
controlBar: {
volumePanel: {inline: false}
},
},function(){
Player.src(src);
Player.on('ended',function(){
Player.play();
})
});
$(".play-btn").on("click", function () {
var html=[];
$(".video-play-bg").css("height","100%");
'<div class="box-img">' +
'<img class="bg-img" src=https://zhibocdn.yabolive.net/comm'+data.room.faceImg+' alt="">' +
'<img class="zhuan" src="images/Loading.png" alt="">' +
'</div>';
$(".video-play-bg").append(html);
$(".video-play-bg").addClass('video-play-bg1').removeClass('video-play-bg');
$(".play-btn").fadeOut(500);
Player.play();
$.ajax({
url: $ip + "/share/updateVisit.html",
type: "post",
data: {
'uid':0,
'os': "WEB",
'cid': "web_gw",
'lang': 2,
'fid': o,
},
success:function(){
}
})
})
} else {
var vplay=data.room.hlsUrl;
$(".play-btn").unbind();
$(".play-btn").on("click", function () {
var html=[];
$(".video-play-bg").css("height","100%");
html+='<video id="videoID" controlsList="nodownload" webkit-playsinline="true" x-webkit-airplay="true" playsinline="true" x5-video-player-type="h5" x5-video-player-fullscreen="true"style="width: 10rem; height:100%; object-fit:fill;position: absolute;z-index: 10" poster="" src='+vplay+'></video>' +
'<div class="box-img">' +
'<img class="bg-img" src=https://zhibocdn.yabolive.net/comm'+data.room.faceImg+' alt="">' +
'<img class="zhuan" src="images/Loading.png" alt="">' +
'</div>';
$(".video-play-bg").html(html);
$(".video-play-bg").addClass('video-play-bg1').removeClass('video-play-bg');
$(".play-btn").fadeOut(500);
document.getElementById('videoID').play();
})
}
}else{
var html =[];
html+='<div class="end">'
if(lang==1){
html+='<span class="text1">Livestream Ended</span>'
html+='<span class="text2">Enter the App to watch</span>'
}else{
html+='<span class="text1">直播已结束</span>'
html+='<span class="text2">进入APP看直播</span>'
}
html+='</div>'
$(".video-play-bg").html(html)
if(lang==1){
$(".end .text2").css("margin-left","-1rem");
$(".end .text2").css("width","6rem")
$(".end .text2").css("margin-top","0.3rem")
}
$(".play-btn").fadeOut(0);
$(".name-more").fadeOut(0);
$(".guanzhu").fadeOut(0);
$(".video-play-bg").css("filter","blur(0px)");
}
}
});
//用戶下載
setInterval(function () {
try{
if (videoID.paused){
$(".play-btn").fadeIn(500);
$(".zhuan").fadeOut(500);
}
}catch(msg){
}
},1000)
}
function browserRedirect() {
var ua = navigator.userAgent.toLowerCase();
var userAgent = navigator.userAgent;
//安卓
if (/android/.test(ua)) {
if (ua.match(/QQ/i) == "qq") {
$(".shadow-img").fadeIn(500)
}
var data = OpenInstall.parseUrlParams();
new OpenInstall({
appKey: key,
preferWakeup: true,
mask:function(){
return '<div id="openinstall_shadow" class="shadow-img"><img src="images/share-img.png" alt=""></div>'
},
onready: function () {
var m = this;
m.schemeWakeup();
m.wakeupOrInstall();
return false;
}
}, data);
//ios
}else if(/iphone|ipad|ipod/.test(ua)){
var data = OpenInstall.parseUrlParams();
if(ua.match(/MicroMessenger/i) == 'micromessenger'){
$(".shadow-img").fadeIn(500)
}
if (ua.match(/QQ/i) == "qq") {
$(".shadow-img").fadeIn(500)
}
//if (userAgent.indexOf("witter") > -1){
// $(".shadow-img").fadeIn(500)
//}
//if (userAgent.indexOf("facebook") > -1){
// $(".shadow-img").fadeIn(500)
//}
//if(ua.match(/MicroMessenger/i) == 'micromessenger'){
// $(".shadow-img").fadeIn(500)
//}
new OpenInstall({
appKey: key,
preferWakeup: true,
mask:function(){
return '<div id="openinstall_shadow" class="shadow-img"><img src="images/share-img.png" alt=""></div>'
},
onready: function () {
var m = this;
m.schemeWakeup();
m.wakeupOrInstall();
return false;
}
}, data);
}
}
})