This repository has been archived by the owner on Apr 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
111 lines (107 loc) · 3.1 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>HLS Player</title>
<style>
*{
margin:0;
padding:0;
}
#player{
position:absolute;
width:100%!important;
height:100%!important;
overflow:hidden;
}
</style>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<script src="jwplayer/jwplayer.js"></script></head>
<body>
<div id="player"></div>
<script>
var hash = window.location.hash;
var temp = (window.location.href+(hash?"#"+hash:"")).split("?")[1].split("&");
var params = {}, pk = "", pks = ["v", "a", "t"];
for (var i=0; i<temp.length; i++) {
var _ = temp[i].split("="), k = _[0], v = _[1];
if (pks.indexOf(k) == -1) {
params[pk] += "&"+decodeURIComponent(k)+(v == undefined?"":"="+decodeURIComponent(v));
continue;
}
params[k] = decodeURIComponent(v);
for (var j=2; j<_.length; j++) {
params[k] += "="+decodeURIComponent(_[j]);
}
pk = k;
}
var temp = document.cookie.split("; ");
var cookie = {}
for (var i=0; i<temp.length; i++) {
var _ = temp[i].split("="), k = _[0], v = _[1];
cookie[k] = decodeURIComponent(v);
}
var vurl = params["v"].split("/");
for (var i=3; i<vurl.length; i++) {
vurl[i] = encodeURIComponent(vurl[i]);
}
vurl = vurl.join("/");
document.title = encodeURIComponent(params["t"])||document.title;
var p = jwplayer("player"), cfg = {
id: "player",
sources: [{"file":vurl}],
controls: true,
title: ""||params["t"],
displaytitle: true,
width: "100%",
height: "100%",
aspectratio: "16:9",
fullscreen: "true",
//image: "",
autostart: params["a"]==1?true:false,
preload: "none",
playbackRateControls: [0.5, 1, 1.25, 1.5, 2, 4],
skin: {
name: "glow",
},
ga: {
label: "title"
},
/*tracks: [{
file: "",
kind: "thumbnails"
}]*/
};
p.setup(cfg);
setTimeout(function() {
document.querySelector('div[aria-label="Playback rates"]').style.display = "none";
var cpr = document.createElement("div");
cpr.style.display = "inline-block";
cpr.style.color = "white";
cpr.style.fontSize = "0.8em";
cpr.innerHTML = document.querySelector('div[aria-label="Playback rates"] li.jw-active-option').textContent;
cpr.addEventListener("click", function(){
var index = -1;
for (var i=0; i<cfg.playbackRateControls.length; i++) {
if (p.getPlaybackRate() == cfg.playbackRateControls[i]) {
break;
}
}
i = (i+1)%cfg.playbackRateControls.length;
p.setPlaybackRate(cfg.playbackRateControls[i]);
cpr.innerHTML = (cfg.playbackRateControls[i])+"x";
});
var tar = document.querySelector('div[aria-label="Playback rates"]');
tar.parentNode.insertBefore(cpr, tar);
}, 1000);
p.setVolume(cookie["volume"]||p.getVolume());
p.on("volume", function(e){
document.cookie = `volume=${p.getVolume()};`;
});
p.setPlaybackRate(parseFloat(cookie["pr"])||p.getPlaybackRate());
p.on("playbackRateChanged", function(e){
document.cookie = `pr=${p.getPlaybackRate()};`;
});
</script>
</body>
</html>