PeerTube/client/src/app/shared/shared-main/video/embed.component.ts

36 lines
1008 B
TypeScript
Raw Normal View History

2021-10-27 11:42:05 +02:00
import { environment } from 'src/environments/environment'
import { Component, Input, OnInit } from '@angular/core'
import { DomSanitizer, SafeHtml } from '@angular/platform-browser'
2022-03-14 14:28:20 +01:00
import { buildVideoOrPlaylistEmbed } from '@root-helpers/video'
2021-10-27 11:42:05 +02:00
import { buildVideoEmbedLink, decorateVideoLink } from '@shared/core-utils'
import { Video } from '@shared/models'
@Component({
selector: 'my-embed',
styleUrls: [ './embed.component.scss' ],
templateUrl: './embed.component.html'
})
export class EmbedComponent implements OnInit {
@Input() video: Pick<Video, 'name' | 'uuid'>
embedHTML: SafeHtml
constructor (private sanitizer: DomSanitizer) {
}
ngOnInit () {
const html = buildVideoOrPlaylistEmbed({
embedUrl: decorateVideoLink({
2021-10-27 11:42:05 +02:00
url: buildVideoEmbedLink(this.video, environment.originServerUrl),
title: false,
warningTitle: false
}),
embedTitle: this.video.name
})
2021-10-27 11:42:05 +02:00
this.embedHTML = this.sanitizer.bypassSecurityTrustHtml(html)
}
}