Adding an method error cathing and a way to force a mehtod.

This commit is contained in:
Zoe Roux 2019-11-25 22:04:44 +01:00
parent 690048e720
commit 2f5c19e133
7 changed files with 74 additions and 45 deletions

View File

@ -56,7 +56,7 @@
"budgets": [ "budgets": [
{ {
"type": "initial", "type": "initial",
"maximumWarning": "2mb", "maximumWarning": "3mb",
"maximumError": "5mb" "maximumError": "5mb"
}, },
{ {

View File

@ -4266,9 +4266,9 @@
"dev": true "dev": true
}, },
"fsevents": { "fsevents": {
"version": "2.0.7", "version": "2.1.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.0.7.tgz", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.2.tgz",
"integrity": "sha512-a7YT0SV3RB+DjYcppwVDLtn13UQnmg0SWZS7ezZD0UjnLwXmy8Zm21GMVGLaFGimIqcvyMQaOJBrop8MyOp1kQ==", "integrity": "sha512-R4wDiBwZ0KzpgOWetKDug1FZcYhqYnUYKtfZYt4mD5SBz76q0KR4Q9o7GIPamsVPGmW3EYPPJ0dOOjvx32ldZA==",
"dev": true, "dev": true,
"optional": true "optional": true
}, },
@ -8601,6 +8601,7 @@
"version": "6.4.0", "version": "6.4.0",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.4.0.tgz", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.4.0.tgz",
"integrity": "sha512-Z9Yfa11F6B9Sg/BK9MnqnQ+aQYicPLtilXBp2yUtDt2JRCE0h26d33EnfO3ZxoNxG0T92OUucP3Ct7cpfkdFfw==", "integrity": "sha512-Z9Yfa11F6B9Sg/BK9MnqnQ+aQYicPLtilXBp2yUtDt2JRCE0h26d33EnfO3ZxoNxG0T92OUucP3Ct7cpfkdFfw==",
"dev": true,
"requires": { "requires": {
"tslib": "^1.9.0" "tslib": "^1.9.0"
} }

View File

@ -27,8 +27,6 @@
"hammerjs": "^2.0.8", "hammerjs": "^2.0.8",
"jquery": "^3.4.1", "jquery": "^3.4.1",
"popper.js": "^1.15.0", "popper.js": "^1.15.0",
"rxjs": "~6.4.0",
"tslib": "^1.10.0",
"zone.js": "~0.9.1" "zone.js": "~0.9.1"
}, },
"devDependencies": { "devDependencies": {

View File

@ -8,7 +8,7 @@ import { Show } from "../../models/show";
templateUrl: './browse.component.html', templateUrl: './browse.component.html',
styleUrls: ['./browse.component.scss'] styleUrls: ['./browse.component.scss']
}) })
export class BrowseComponent implements OnInit export class BrowseComponent
{ {
@Input() shows: Show[]; @Input() shows: Show[];
sortType: string = "title"; sortType: string = "title";
@ -16,13 +16,13 @@ export class BrowseComponent implements OnInit
sortTypes: string[] = ["title", "release date"]; sortTypes: string[] = ["title", "release date"];
constructor(private route: ActivatedRoute, private sanitizer: DomSanitizer) { } constructor(private route: ActivatedRoute, private sanitizer: DomSanitizer)
{
ngOnInit() this.route.data.subscribe((data) =>
{ {
if (this.shows == null) this.shows = data.shows;
this.shows = this.route.snapshot.data.shows; });
} }
getThumb(slug: string) getThumb(slug: string)
{ {

View File

@ -8,16 +8,17 @@ import { DomSanitizer } from "@angular/platform-browser";
templateUrl: './collection.component.html', templateUrl: './collection.component.html',
styleUrls: ['./collection.component.scss'] styleUrls: ['./collection.component.scss']
}) })
export class CollectionComponent implements OnInit export class CollectionComponent
{ {
collection: Collection; collection: Collection;
constructor(private route: ActivatedRoute, private sanitizer: DomSanitizer) { } constructor(private route: ActivatedRoute, private sanitizer: DomSanitizer)
{
ngOnInit() this.route.data.subscribe((data) =>
{ {
this.collection = this.route.snapshot.data.collection; this.collection = data.collection;
} });
}
getThumb() getThumb()
{ {

View File

@ -40,6 +40,8 @@ export class PlayerComponent implements OnInit
playTooltip: string = "Pause"; //Text used in the play tooltip playTooltip: string = "Pause"; //Text used in the play tooltip
fullscreenTooltip: string = "Fullscreen"; //Text used in the fullscreen tooltip fullscreenTooltip: string = "Fullscreen"; //Text used in the fullscreen tooltip
playMethod: method;
private player: HTMLVideoElement; private player: HTMLVideoElement;
private thumb: HTMLElement; private thumb: HTMLElement;
private progress: HTMLElement; private progress: HTMLElement;
@ -127,6 +129,19 @@ export class PlayerComponent implements OnInit
this.next(); this.next();
} }
this.player.onerror = () =>
{
if (this.playMethod == method.transcode)
{
this.snackBar.open("This episode can't be played.", null, { horizontalPosition: "left", panelClass: ['snackError'], duration: 10000 });
}
else
{
this.playMethod += 1;
this.selectPlayMethod();
}
}
let progressBar: HTMLElement = document.getElementById("progress-bar") as HTMLElement; let progressBar: HTMLElement = document.getElementById("progress-bar") as HTMLElement;
$(progressBar).click((event) => $(progressBar).click((event) =>
{ {
@ -339,21 +354,14 @@ export class PlayerComponent implements OnInit
init() init()
{ {
let playbackMethod = getPlaybackMethod(this.player, this.item); let queryMethod: string = this.route.snapshot.queryParams["method"];
if (playbackMethod == method.direct) console.log("Query method: " + queryMethod);
{ if (queryMethod)
this.player.src = "/video/" + this.item.link; this.playMethod = method[queryMethod];
} else
else if (playbackMethod == method.transmux) this.playMethod = getPlaybackMethod(this.player, this.item);
{
var dashPlayer = MediaPlayer().create(); this.selectPlayMethod();
dashPlayer.initialize(this.player, "/video/transmux/" + this.item.link + "/", true);
}
else
{
var dashPlayer = MediaPlayer().create();
dashPlayer.initialize(this.player, "/video/transcode/" + this.item.link + "/", true);
}
let sub: string = this.route.snapshot.queryParams["sub"]; let sub: string = this.route.snapshot.queryParams["sub"];
if (sub != null) if (sub != null)
@ -370,6 +378,24 @@ export class PlayerComponent implements OnInit
}, 750); }, 750);
} }
selectPlayMethod()
{
if (this.playMethod == method.direct)
{
this.player.src = "/video/" + this.item.link;
}
else if (this.playMethod == method.transmux)
{
var dashPlayer = MediaPlayer().create();
dashPlayer.initialize(this.player, "/video/transmux/" + this.item.link + "/", true);
}
else
{
var dashPlayer = MediaPlayer().create();
dashPlayer.initialize(this.player, "/video/transcode/" + this.item.link + "/", true);
}
}
back() back()
{ {
this.location.back(); this.location.back();

View File

@ -25,23 +25,26 @@ export class ShowDetailsComponent implements OnInit
this.route.queryParams.subscribe(params => this.route.queryParams.subscribe(params =>
{ {
this.season = params["season"]; this.season = params["season"];
}); });
this.route.data.subscribe(data =>
{
this.show = data.show;
this.title.setTitle(this.show.title + " - Kyoo");
if (this.season == null || this.show.seasons.find(x => x.seasonNumber == this.season) == null)
this.season = 1;
this.getEpisodes();
});
} }
ngOnInit() ngOnInit()
{ {
this.show = this.route.snapshot.data.show;
this.title.setTitle(this.show.title + " - Kyoo");
if (this.season == null || this.show.seasons.find(x => x.seasonNumber == this.season) == null)
this.season = 1;
this.toolbar = document.getElementById("toolbar"); this.toolbar = document.getElementById("toolbar");
this.backdrop = document.getElementById("backdrop"); this.backdrop = document.getElementById("backdrop");
window.addEventListener("scroll", this.scroll, true); window.addEventListener("scroll", this.scroll, true);
this.toolbar.setAttribute("style", `background-color: rgba(0, 0, 0, 0) !important`); this.toolbar.setAttribute("style", `background-color: rgba(0, 0, 0, 0) !important`);
this.getEpisodes();
} }
ngOnDestroy() ngOnDestroy()