aboutsummaryrefslogtreecommitdiffstats
path: root/src/client/players/Raw.hx
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2021-07-05 17:09:56 +0300
committerRblSb <msrblsb@gmail.com>2021-07-05 17:09:56 +0300
commitcf78d464be214eedcd7909001ece2aa0a216d136 (patch)
tree5801ef0ca01589ed923c961a93b30278df9ea9d3 /src/client/players/Raw.hx
parentede45cea8706eb8540e466df9861c2af8ebf9c44 (diff)
vtt/srt subs support
Diffstat (limited to 'src/client/players/Raw.hx')
-rw-r--r--src/client/players/Raw.hx42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/client/players/Raw.hx b/src/client/players/Raw.hx
index ea51e97..5889732 100644
--- a/src/client/players/Raw.hx
+++ b/src/client/players/Raw.hx
@@ -54,11 +54,8 @@ class Raw implements IPlayer {
}
titleInput.value = "";
- var subs = "";
- if (JsApi.hasSubtitleSupport()) {
- subs = subsInput.value.trim();
- subsInput.value = "";
- }
+ final subs = subsInput.value.trim();
+ subsInput.value = "";
final video = document.createVideoElement();
video.src = url;
video.onerror = e -> {
@@ -101,24 +98,27 @@ class Raw implements IPlayer {
}
if (video != null) {
video.src = url;
- if (isHls) initHlsSource(video, url);
- restartControlsHider();
- return;
- }
- video = document.createVideoElement();
- video.id = "videoplayer";
- video.src = url;
- restartControlsHider();
- video.oncanplaythrough = player.onCanBePlayed;
- video.onseeking = player.onSetTime;
- video.onplay = e -> {
- playAllowed = true;
- player.onPlay();
+ for (element in video.children) {
+ if (element.nodeName != "TRACK") continue;
+ element.remove();
+ }
+ } else {
+ video = document.createVideoElement();
+ video.id = "videoplayer";
+ video.src = url;
+ video.oncanplaythrough = player.onCanBePlayed;
+ video.onseeking = player.onSetTime;
+ video.onplay = e -> {
+ playAllowed = true;
+ player.onPlay();
+ }
+ video.onpause = player.onPause;
+ video.onratechange = player.onRateChange;
+ playerEl.appendChild(video);
}
- video.onpause = player.onPause;
- video.onratechange = player.onRateChange;
- playerEl.appendChild(video);
if (isHls) initHlsSource(video, url);
+ restartControlsHider();
+ RawSubs.loadSubs(item, video);
}
function restartControlsHider():Void {
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage