mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Finishing subrip player support for the web app.
This commit is contained in:
parent
f67293d065
commit
cb306d6a34
@ -3,6 +3,8 @@
|
|||||||
<video id="player" poster="backdrop/{{this.item.showSlug}}" autoplay muted (click)="tooglePlayback()">
|
<video id="player" poster="backdrop/{{this.item.showSlug}}" autoplay muted (click)="tooglePlayback()">
|
||||||
<source src="/api/video/{{this.item.link}}" />
|
<source src="/api/video/{{this.item.link}}" />
|
||||||
<source src="/api/video/{{this.item.link}}/stream" type="video/mp4" />
|
<source src="/api/video/{{this.item.link}}/stream" type="video/mp4" />
|
||||||
|
|
||||||
|
<!--<track src="/api/subtitle/clannad-s1e1.eng.vtt" lang="English" srclang="en" default/>-->
|
||||||
</video>
|
</video>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -91,7 +93,7 @@
|
|||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div *ngFor="let subtitle of this.item.subtitles">
|
<div *ngFor="let subtitle of this.item.subtitles">
|
||||||
<button [ngClass]="{'selected': this.selectedSubtitle == subtitle}" mat-menu-item *ngIf="subtitle.codec == 'ass'; else elseBlock" (click)="selectSubtitle(subtitle)">
|
<button [ngClass]="{'selected': this.selectedSubtitle == subtitle}" mat-menu-item *ngIf="subtitle.codec == 'ass' || subtitle.codec == 'subrip'; else elseBlock" (click)="selectSubtitle(subtitle)">
|
||||||
<span>{{subtitle.displayName}}</span>
|
<span>{{subtitle.displayName}}</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
@ -343,7 +343,7 @@ export class PlayerComponent implements OnInit
|
|||||||
fullscreen()
|
fullscreen()
|
||||||
{
|
{
|
||||||
if (document.fullscreenElement == null)
|
if (document.fullscreenElement == null)
|
||||||
document.getElementById("root").requestFullscreen();
|
document.body.requestFullscreen();
|
||||||
else
|
else
|
||||||
document.exitFullscreen();
|
document.exitFullscreen();
|
||||||
}
|
}
|
||||||
@ -400,16 +400,42 @@ export class PlayerComponent implements OnInit
|
|||||||
{
|
{
|
||||||
this.snackBar.open("Subtitle removed.", null, { verticalPosition: "top", horizontalPosition: "right", duration: 750, panelClass: "info-panel" });
|
this.snackBar.open("Subtitle removed.", null, { verticalPosition: "top", horizontalPosition: "right", duration: 750, panelClass: "info-panel" });
|
||||||
SubtitleManager.remove(this.player);
|
SubtitleManager.remove(this.player);
|
||||||
|
this.removeHtmlTrack();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.snackBar.open(subtitle.displayName + " subtitle loaded.", null, { verticalPosition: "top", horizontalPosition: "right", duration: 750, panelClass: "info-panel" });
|
this.snackBar.open(subtitle.displayName + " subtitle loaded.", null, { verticalPosition: "top", horizontalPosition: "right", duration: 750, panelClass: "info-panel" });
|
||||||
|
this.removeHtmlTrack();
|
||||||
|
|
||||||
if (subtitle.codec == "ass")
|
if (subtitle.codec == "ass")
|
||||||
SubtitleManager.add(this.player, subtitle.link, true);
|
SubtitleManager.add(this.player, subtitle.link, true);
|
||||||
|
|
||||||
|
else if (subtitle.codec == "subrip")
|
||||||
|
{
|
||||||
|
SubtitleManager.remove(this.player);
|
||||||
|
|
||||||
|
let track = document.createElement("track");
|
||||||
|
track.kind = "subtitles";
|
||||||
|
track.label = subtitle.displayName;
|
||||||
|
track.srclang = subtitle.language;
|
||||||
|
track.src = subtitle.link.replace(".srt", ".vtt");
|
||||||
|
track.default = true;
|
||||||
|
track.onload = () =>
|
||||||
|
{
|
||||||
|
this.player.textTracks[0].mode = "showing";
|
||||||
|
};
|
||||||
|
this.player.appendChild(track);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeHtmlTrack()
|
||||||
|
{
|
||||||
|
let elements = this.player.getElementsByTagName("track");
|
||||||
|
if (elements.length > 0)
|
||||||
|
elements.item(0).remove();
|
||||||
|
}
|
||||||
|
|
||||||
getThumb(url: string)
|
getThumb(url: string)
|
||||||
{
|
{
|
||||||
return this.sanitizer.bypassSecurityTrustStyle("url(" + url + ")");
|
return this.sanitizer.bypassSecurityTrustStyle("url(" + url + ")");
|
||||||
|
@ -90,7 +90,7 @@ namespace Kyoo.Controllers
|
|||||||
|
|
||||||
public class ConvertSubripToVtt : IActionResult
|
public class ConvertSubripToVtt : IActionResult
|
||||||
{
|
{
|
||||||
private string path;
|
private readonly string path;
|
||||||
private string lastLine = "";
|
private string lastLine = "";
|
||||||
|
|
||||||
public ConvertSubripToVtt(string subtitlePath)
|
public ConvertSubripToVtt(string subtitlePath)
|
||||||
@ -133,7 +133,7 @@ namespace Kyoo.Controllers
|
|||||||
line = null;
|
line = null;
|
||||||
|
|
||||||
if (lastLine == null) //The line is a timecode only if the last line is an index line and we already set it to null.
|
if (lastLine == null) //The line is a timecode only if the last line is an index line and we already set it to null.
|
||||||
line = line.Replace(',', '.'); //This is never called.
|
line = line.Replace(',', '.');
|
||||||
|
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user