-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.php
181 lines (167 loc) · 6.02 KB
/
test.php
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
<?php
header("Access-Control-Allow-Origin: *");
?>
<head>
<link href="https://vjs.zencdn.net/8.0.4/video-js.css" rel="stylesheet" />
<link href="https://www.ranrom.xyz/test/libjass.css" rel="stylesheet">
<!-- If you'd like to support IE8 (for Video.js versions prior to v7) -->
<!-- <script src="https://vjs.zencdn.net/ie8/1.1.2/videojs-ie8.min.js"></script> -->
</head>
<body>
<video
id="my-video"
class="video-js"
crossorigin="anonymous"
controls=true
preload="true"
width="1280"
height="720"
poster="MY_VIDEO_POSTER.jpg"
data-setup="{}"
options="{navigationUI: 'hide'}"
>
<source src="https://kiyo.ranrom.xyz/vid/anime/The_Angle_Next_Door_Spoils_Me_rotten/The%20Angel%20Next%20Door%20Spoils%20Me%20Rotten%20-%2001.mp4" type="video/mp4">
<!--track kind="subtitles" src="https://kiyo.ranrom.xyz/vid/anime/The_Angle_Next_Door_Spoils_Me_rotten/esp1.captions.vtt" srclang="en" label="English (VTT)"--!>
<p class="vjs-no-js">
To view this video please enable JavaScript, and consider upgrading to a
web browser that
<a href="https://videojs.com/html5-video-support/" target="_blank"
>supports HTML5 video</a
>
</p>
</video>
<script src="https://vjs.zencdn.net/8.0.4/video.min.js"></script>
<script src="//cdn.sc.gl/videojs-hotkeys/latest/videojs.hotkeys.min.js"></script>
<script src="https://www.ranrom.xyz/test/libjass.js"></script>
<link href="https://www.ranrom.xyz/test/videojs.ass.css" rel="stylesheet">
<script src="https://www.ranrom.xyz/test/videojs.ass.js"></script>
<script>
videojs('my-video', {
html5: {
nativeTextTracks: false
},
plugins: {
ass: {
subtitles: [{src: 'https://kiyo.ranrom.xyz/vid/anime/The_Angle_Next_Door_Spoils_Me_rotten/esp1.ssa', label: 'English (SSA)', srclang: 'en', 'default': false, 'delay': -0.1/*-0.1*/}]
}
}
});
var HasSwitched = false;
var player = videojs('my-video');
var tracks = player.textTracks();
var delayInMilliseconds = 1500; //1 second
player.on('playing', function() {
if(!HasSwitched) {
HasSwitched = true;
setTimeout(function() {
for (var i = 0; i < tracks.length; i++) {
var track = tracks[i];
if (track.kind === 'subtitles' && track.language === 'en') {
track.mode = 'showing';
}
}
}, delayInMilliseconds);
}
});
videojs('my-video').ready(function() {
this.hotkeys({
volumeStep: 0.1,
seekStep: 5,
enableMute: true,
enableFullscreen: true,
enableNumbers: false,
enableVolumeScroll: true,
enableHoverScroll: true,
captureDocumentHotkeys: true,
documentHotkeysFocusElementFilter: e => e.tagName.toLowerCase() === "body",
// Mimic VLC seek behavior, and default to 5.
seekStep: function(e) {
if (e.ctrlKey && e.altKey) {
return 5*60;
} else if (e.ctrlKey) {
return 60;
} else if (e.altKey) {
return 10;
} else {
return 5;
}
},
// Enhance existing simple hotkey with a complex hotkey
fullscreenKey: function(e) {
// fullscreen with the F key or Ctrl+Enter
return ((e.which === 70) || (e.ctrlKey && e.which === 13));
},
// Custom Keys
customKeys: {
// Add new simple hotkey
simpleKey: {
key: function(e) {
// Toggle something with S Key
return (e.which === 83);
},
handler: function(player, options, e) {
// Example
if (player.paused()) {
player.play();
} else {
player.pause();
}
}
},
// Add new complex hotkey
complexKey: {
key: function(e) {
// Toggle something with CTRL + D Key
return (e.ctrlKey && e.which === 68);
},
handler: function(player, options, event) {
// Example
if (options.enableMute) {
player.muted(!player.muted());
}
}
},
// Override number keys example from https://github.com/ctd1500/videojs-hotkeys/pull/36
numbersKey: {
key: function(event) {
// Override number keys
return ((event.which > 47 && event.which < 59) || (event.which > 95 && event.which < 106));
},
handler: function(player, options, event) {
// Do not handle if enableModifiersForNumbers set to false and keys are Ctrl, Cmd or Alt
if (options.enableModifiersForNumbers || !(event.metaKey || event.ctrlKey || event.altKey)) {
var sub = 48;
if (event.which > 95) {
sub = 96;
}
var number = event.which - sub;
player.currentTime(player.duration() * number * 0.1);
}
}
},
emptyHotkey: {
// Empty
},
withoutKey: {
handler: function(player, options, event) {
console.log('withoutKey handler');
}
},
withoutHandler: {
key: function(e) {
return true;
}
},
malformedKey: {
key: function() {
console.log('I have a malformed customKey. The Key function must return a boolean.');
},
handler: function(player, options, event) {
//Empty
}
}
}
});
});
</script>
</body>