mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-23 15:30:34 -04:00
Implementing authorization on the video player
This commit is contained in:
parent
39dc1460e9
commit
76fbdce3be
@ -130,7 +130,7 @@ export class AppModule
|
|||||||
client_id: 'kyoo.webapp',
|
client_id: 'kyoo.webapp',
|
||||||
response_type: "code",
|
response_type: "code",
|
||||||
trigger_authorization_result_event: true,
|
trigger_authorization_result_event: true,
|
||||||
scope: "openid profile kyoo.read offline_access",
|
scope: "openid profile offline_access kyoo.read kyoo.play",
|
||||||
silent_renew: false,
|
silent_renew: false,
|
||||||
silent_renew_url: "/silent",
|
silent_renew_url: "/silent",
|
||||||
use_refresh_token: false,
|
use_refresh_token: false,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
|
import {Component, Inject, Injector, OnInit, ViewEncapsulation} from '@angular/core';
|
||||||
import { MatSnackBar } from "@angular/material/snack-bar";
|
import { MatSnackBar } from "@angular/material/snack-bar";
|
||||||
import { DomSanitizer, Title } from "@angular/platform-browser";
|
import { DomSanitizer, Title } from "@angular/platform-browser";
|
||||||
import { ActivatedRoute, Event, NavigationCancel, NavigationEnd, NavigationStart, Router } from "@angular/router";
|
import { ActivatedRoute, Event, NavigationCancel, NavigationEnd, NavigationStart, Router } from "@angular/router";
|
||||||
@ -6,6 +6,7 @@ import { Track, WatchItem } from "../../models/watch-item";
|
|||||||
import { Location } from "@angular/common";
|
import { Location } from "@angular/common";
|
||||||
import * as Hls from "hls.js"
|
import * as Hls from "hls.js"
|
||||||
import { getPlaybackMethod, method, getWhatIsSupported, SupportList } from "../../videoSupport/playbackMethodDetector";
|
import { getPlaybackMethod, method, getWhatIsSupported, SupportList } from "../../videoSupport/playbackMethodDetector";
|
||||||
|
import {OidcSecurityService} from "angular-auth-oidc-client";
|
||||||
|
|
||||||
declare var SubtitleManager: any;
|
declare var SubtitleManager: any;
|
||||||
|
|
||||||
@ -51,8 +52,11 @@ export class PlayerComponent implements OnInit
|
|||||||
private thumb: HTMLElement;
|
private thumb: HTMLElement;
|
||||||
private progress: HTMLElement;
|
private progress: HTMLElement;
|
||||||
private buffered: HTMLElement;
|
private buffered: HTMLElement;
|
||||||
|
|
||||||
|
|
||||||
|
private oidcSecurity: OidcSecurityService;
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute, private sanitizer: DomSanitizer, private snackBar: MatSnackBar, private title: Title, private router: Router, private location: Location) { }
|
constructor(private route: ActivatedRoute, private sanitizer: DomSanitizer, private snackBar: MatSnackBar, private title: Title, private router: Router, private location: Location, private injector: Injector) { }
|
||||||
|
|
||||||
ngOnInit()
|
ngOnInit()
|
||||||
{
|
{
|
||||||
@ -399,6 +403,16 @@ export class PlayerComponent implements OnInit
|
|||||||
selectPlayMethod(playMethod: method)
|
selectPlayMethod(playMethod: method)
|
||||||
{
|
{
|
||||||
this.playMethod = playMethod;
|
this.playMethod = playMethod;
|
||||||
|
|
||||||
|
if (this.oidcSecurity === undefined)
|
||||||
|
this.oidcSecurity = this.injector.get(OidcSecurityService);
|
||||||
|
this.hlsPlayer.config.xhrSetup = (xhr, url) =>
|
||||||
|
{
|
||||||
|
const token = this.oidcSecurity.getToken();
|
||||||
|
if (token)
|
||||||
|
xhr.setRequestHeader("Authorization", "Bearer " + token);
|
||||||
|
};
|
||||||
|
|
||||||
if (this.playMethod == method.direct)
|
if (this.playMethod == method.direct)
|
||||||
{
|
{
|
||||||
this.player.src = "/video/" + this.item.link;
|
this.player.src = "/video/" + this.item.link;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user