diff options
Diffstat (limited to 'client/src/app/shared/shared-share-modal/video-share.component.ts')
-rw-r--r-- | client/src/app/shared/shared-share-modal/video-share.component.ts | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/client/src/app/shared/shared-share-modal/video-share.component.ts b/client/src/app/shared/shared-share-modal/video-share.component.ts index d59f338c7..36a4d7520 100644 --- a/client/src/app/shared/shared-share-modal/video-share.component.ts +++ b/client/src/app/shared/shared-share-modal/video-share.component.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | import { Component, ElementRef, Input, ViewChild } from '@angular/core' | 1 | import { Component, ElementRef, Input, ViewChild } from '@angular/core' |
2 | import { DomSanitizer, SafeHtml } from '@angular/platform-browser' | 2 | import { DomSanitizer, SafeHtml } from '@angular/platform-browser' |
3 | import { ServerService } from '@app/core' | ||
3 | import { VideoDetails } from '@app/shared/shared-main' | 4 | import { VideoDetails } from '@app/shared/shared-main' |
4 | import { VideoPlaylist } from '@app/shared/shared-video-playlist' | 5 | import { VideoPlaylist } from '@app/shared/shared-video-playlist' |
5 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | 6 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' |
@@ -21,6 +22,8 @@ type Customizations = { | |||
21 | originUrl: boolean | 22 | originUrl: boolean |
22 | autoplay: boolean | 23 | autoplay: boolean |
23 | muted: boolean | 24 | muted: boolean |
25 | |||
26 | embedP2P: boolean | ||
24 | title: boolean | 27 | title: boolean |
25 | warningTitle: boolean | 28 | warningTitle: boolean |
26 | controls: boolean | 29 | controls: boolean |
@@ -54,7 +57,8 @@ export class VideoShareComponent { | |||
54 | 57 | ||
55 | constructor ( | 58 | constructor ( |
56 | private modalService: NgbModal, | 59 | private modalService: NgbModal, |
57 | private sanitizer: DomSanitizer | 60 | private sanitizer: DomSanitizer, |
61 | private server: ServerService | ||
58 | ) { } | 62 | ) { } |
59 | 63 | ||
60 | show (currentVideoTimestamp?: number, currentPlaylistPosition?: number) { | 64 | show (currentVideoTimestamp?: number, currentPlaylistPosition?: number) { |
@@ -78,6 +82,8 @@ export class VideoShareComponent { | |||
78 | autoplay: false, | 82 | autoplay: false, |
79 | muted: false, | 83 | muted: false, |
80 | 84 | ||
85 | embedP2P: this.server.getHTMLConfig().defaults.p2p.embed.enabled, | ||
86 | |||
81 | // Embed options | 87 | // Embed options |
82 | title: true, | 88 | title: true, |
83 | warningTitle: true, | 89 | warningTitle: true, |
@@ -87,6 +93,11 @@ export class VideoShareComponent { | |||
87 | set: (target, prop, value) => { | 93 | set: (target, prop, value) => { |
88 | target[prop] = value | 94 | target[prop] = value |
89 | 95 | ||
96 | if (prop === 'embedP2P') { | ||
97 | // Auto enabled warning title if P2P is enabled | ||
98 | this.customizations.warningTitle = value | ||
99 | } | ||
100 | |||
90 | this.updateEmbedCode() | 101 | this.updateEmbedCode() |
91 | 102 | ||
92 | return true | 103 | return true |
@@ -101,7 +112,7 @@ export class VideoShareComponent { | |||
101 | } | 112 | } |
102 | 113 | ||
103 | getVideoIframeCode () { | 114 | getVideoIframeCode () { |
104 | const embedUrl = decorateVideoLink({ url: this.video.embedUrl, ...this.getVideoOptions() }) | 115 | const embedUrl = decorateVideoLink({ url: this.video.embedUrl, ...this.getVideoOptions(true) }) |
105 | 116 | ||
106 | return buildVideoOrPlaylistEmbed(embedUrl, this.video.name) | 117 | return buildVideoOrPlaylistEmbed(embedUrl, this.video.name) |
107 | } | 118 | } |
@@ -120,7 +131,7 @@ export class VideoShareComponent { | |||
120 | return decorateVideoLink({ | 131 | return decorateVideoLink({ |
121 | url, | 132 | url, |
122 | 133 | ||
123 | ...this.getVideoOptions() | 134 | ...this.getVideoOptions(false) |
124 | }) | 135 | }) |
125 | } | 136 | } |
126 | 137 | ||
@@ -165,7 +176,21 @@ export class VideoShareComponent { | |||
165 | } | 176 | } |
166 | } | 177 | } |
167 | 178 | ||
168 | private getVideoOptions () { | 179 | private getVideoOptions (forEmbed: boolean) { |
180 | const embedOptions = forEmbed | ||
181 | ? { | ||
182 | title: this.customizations.title, | ||
183 | warningTitle: this.customizations.warningTitle, | ||
184 | controls: this.customizations.controls, | ||
185 | peertubeLink: this.customizations.peertubeLink, | ||
186 | |||
187 | // If using default value, we don't need to specify it | ||
188 | p2p: this.customizations.embedP2P === this.server.getHTMLConfig().defaults.p2p.embed.enabled | ||
189 | ? undefined | ||
190 | : this.customizations.embedP2P | ||
191 | } | ||
192 | : {} | ||
193 | |||
169 | return { | 194 | return { |
170 | startTime: this.customizations.startAtCheckbox ? this.customizations.startAt : undefined, | 195 | startTime: this.customizations.startAtCheckbox ? this.customizations.startAt : undefined, |
171 | stopTime: this.customizations.stopAtCheckbox ? this.customizations.stopAt : undefined, | 196 | stopTime: this.customizations.stopAtCheckbox ? this.customizations.stopAt : undefined, |
@@ -176,10 +201,7 @@ export class VideoShareComponent { | |||
176 | autoplay: this.customizations.autoplay, | 201 | autoplay: this.customizations.autoplay, |
177 | muted: this.customizations.muted, | 202 | muted: this.customizations.muted, |
178 | 203 | ||
179 | title: this.customizations.title, | 204 | ...embedOptions |
180 | warningTitle: this.customizations.warningTitle, | ||
181 | controls: this.customizations.controls, | ||
182 | peertubeLink: this.customizations.peertubeLink | ||
183 | } | 205 | } |
184 | } | 206 | } |
185 | } | 207 | } |