diff options
Diffstat (limited to 'client/src/app/shared/shared-main/video/embed.component.ts')
-rw-r--r-- | client/src/app/shared/shared-main/video/embed.component.ts | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/client/src/app/shared/shared-main/video/embed.component.ts b/client/src/app/shared/shared-main/video/embed.component.ts new file mode 100644 index 000000000..4732efa44 --- /dev/null +++ b/client/src/app/shared/shared-main/video/embed.component.ts | |||
@@ -0,0 +1,35 @@ | |||
1 | import { buildVideoOrPlaylistEmbed } from 'src/assets/player/utils' | ||
2 | import { environment } from 'src/environments/environment' | ||
3 | import { Component, Input, OnInit } from '@angular/core' | ||
4 | import { DomSanitizer, SafeHtml } from '@angular/platform-browser' | ||
5 | import { buildVideoEmbedLink, decorateVideoLink } from '@shared/core-utils' | ||
6 | import { Video } from '@shared/models' | ||
7 | |||
8 | @Component({ | ||
9 | selector: 'my-embed', | ||
10 | styleUrls: [ './embed.component.scss' ], | ||
11 | templateUrl: './embed.component.html' | ||
12 | }) | ||
13 | export class EmbedComponent implements OnInit { | ||
14 | @Input() video: Pick<Video, 'name' | 'uuid'> | ||
15 | |||
16 | embedHTML: SafeHtml | ||
17 | |||
18 | constructor (private sanitizer: DomSanitizer) { | ||
19 | |||
20 | } | ||
21 | |||
22 | ngOnInit () { | ||
23 | const html = buildVideoOrPlaylistEmbed( | ||
24 | decorateVideoLink({ | ||
25 | url: buildVideoEmbedLink(this.video, environment.originServerUrl), | ||
26 | |||
27 | title: false, | ||
28 | warningTitle: false | ||
29 | }), | ||
30 | this.video.name | ||
31 | ) | ||
32 | |||
33 | this.embedHTML = this.sanitizer.bypassSecurityTrustHtml(html) | ||
34 | } | ||
35 | } | ||