-
Notifications
You must be signed in to change notification settings - Fork 1
/
stream.js
63 lines (59 loc) · 1.84 KB
/
stream.js
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
$(function () {
init();
});
function init() {
$.ajax({
url: 'https://live.wmapi.net/v1/info/stream/' + getQueryVariable('stream'),
dataType: 'json',
success: function (result) {
console.log(result);
if (result.ret != 0) {
Swal.fire({
icon: 'error',
title: 'Oops!',
text: ret.msg
});
OSPF();
} else {
if (result.data.status == 'ended') {
Swal.fire({
icon: 'info',
title: '来晚了',
text: '该直播已结束'
});
OSPF();
} else {
if (result.data.title != null) {
$('#title').text(result.data.title);
}
$('#subtitle').text('Streamer: ' + result.data.streamer);
url = result.data.play_url;
mirror = getQueryVariable('mirror');
if (mirror != false && isEndpoint(mirror)) {
url = mirror + getQueryVariable('stream') + '.m3u8';
}
const dp = new DPlayer({
container: document.getElementById('dplayer'),
live: true,
autoplay: true,
video: {
url: url
}
});
}
}
},
complete: function (XHR, TS) { XHR = null }
});
}
function OSPF()
{
const dp = new DPlayer({
container: document.getElementById('dplayer'),
live: true,
autoplay: true,
video: {
url: 'OSPF.mp4'
}
});
}