diff options
Diffstat (limited to 'client/src/app/+videos/+video-watch/modal/video-share.component.ts')
-rw-r--r-- | client/src/app/+videos/+video-watch/modal/video-share.component.ts | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/client/src/app/+videos/+video-watch/modal/video-share.component.ts b/client/src/app/+videos/+video-watch/modal/video-share.component.ts index 23c562273..d9171fe0e 100644 --- a/client/src/app/+videos/+video-watch/modal/video-share.component.ts +++ b/client/src/app/+videos/+video-watch/modal/video-share.component.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { Component, ElementRef, Input, ViewChild } from '@angular/core' | 1 | import { Component, ElementRef, Input, ViewChild } from '@angular/core' |
2 | import { buildVideoEmbed, buildVideoLink } from '../../../../assets/player/utils' | 2 | import { buildVideoOrPlaylistEmbed, buildVideoLink, buildPlaylistLink } from '../../../../assets/player/utils' |
3 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | 3 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' |
4 | import { VideoCaption } from '@shared/models' | 4 | import { VideoCaption } from '@shared/models' |
5 | import { VideoDetails } from '@app/shared/shared-main' | 5 | import { VideoDetails } from '@app/shared/shared-main' |
@@ -24,6 +24,8 @@ type Customizations = { | |||
24 | peertubeLink: boolean | 24 | peertubeLink: boolean |
25 | } | 25 | } |
26 | 26 | ||
27 | type TabId = 'url' | 'qrcode' | 'embed' | ||
28 | |||
27 | @Component({ | 29 | @Component({ |
28 | selector: 'my-video-share', | 30 | selector: 'my-video-share', |
29 | templateUrl: './video-share.component.html', | 31 | templateUrl: './video-share.component.html', |
@@ -36,14 +38,18 @@ export class VideoShareComponent { | |||
36 | @Input() videoCaptions: VideoCaption[] = [] | 38 | @Input() videoCaptions: VideoCaption[] = [] |
37 | @Input() playlist: VideoPlaylist = null | 39 | @Input() playlist: VideoPlaylist = null |
38 | 40 | ||
39 | activeId: 'url' | 'qrcode' | 'embed' = 'url' | 41 | activeVideoId: TabId = 'url' |
42 | activePlaylistId: TabId = 'url' | ||
43 | |||
40 | customizations: Customizations | 44 | customizations: Customizations |
41 | isAdvancedCustomizationCollapsed = true | 45 | isAdvancedCustomizationCollapsed = true |
42 | includeVideoInPlaylist = false | 46 | includeVideoInPlaylist = false |
43 | 47 | ||
48 | private playlistPosition: number = null | ||
49 | |||
44 | constructor (private modalService: NgbModal) { } | 50 | constructor (private modalService: NgbModal) { } |
45 | 51 | ||
46 | show (currentVideoTimestamp?: number) { | 52 | show (currentVideoTimestamp?: number, currentPlaylistPosition?: number) { |
47 | let subtitle: string | 53 | let subtitle: string |
48 | if (this.videoCaptions.length !== 0) { | 54 | if (this.videoCaptions.length !== 0) { |
49 | subtitle = this.videoCaptions[0].language.id | 55 | subtitle = this.videoCaptions[0].language.id |
@@ -70,19 +76,28 @@ export class VideoShareComponent { | |||
70 | peertubeLink: true | 76 | peertubeLink: true |
71 | } | 77 | } |
72 | 78 | ||
79 | this.playlistPosition = currentPlaylistPosition | ||
80 | |||
73 | this.modalService.open(this.modal, { centered: true }) | 81 | this.modalService.open(this.modal, { centered: true }) |
74 | } | 82 | } |
75 | 83 | ||
76 | getVideoIframeCode () { | 84 | getVideoIframeCode () { |
77 | const options = this.getOptions(this.video.embedUrl) | 85 | const options = this.getVideoOptions(this.video.embedUrl) |
78 | 86 | ||
79 | const embedUrl = buildVideoLink(options) | 87 | const embedUrl = buildVideoLink(options) |
80 | return buildVideoEmbed(embedUrl) | 88 | return buildVideoOrPlaylistEmbed(embedUrl) |
89 | } | ||
90 | |||
91 | getPlaylistIframeCode () { | ||
92 | const options = this.getPlaylistOptions(this.playlist.embedUrl) | ||
93 | |||
94 | const embedUrl = buildPlaylistLink(options) | ||
95 | return buildVideoOrPlaylistEmbed(embedUrl) | ||
81 | } | 96 | } |
82 | 97 | ||
83 | getVideoUrl () { | 98 | getVideoUrl () { |
84 | const baseUrl = window.location.origin + '/videos/watch/' + this.video.uuid | 99 | const baseUrl = window.location.origin + '/videos/watch/' + this.video.uuid |
85 | const options = this.getOptions(baseUrl) | 100 | const options = this.getVideoOptions(baseUrl) |
86 | 101 | ||
87 | return buildVideoLink(options) | 102 | return buildVideoLink(options) |
88 | } | 103 | } |
@@ -99,15 +114,23 @@ export class VideoShareComponent { | |||
99 | return window.location.protocol === 'http:' | 114 | return window.location.protocol === 'http:' |
100 | } | 115 | } |
101 | 116 | ||
102 | isInEmbedTab () { | 117 | isVideoInEmbedTab () { |
103 | return this.activeId === 'embed' | 118 | return this.activeVideoId === 'embed' |
104 | } | 119 | } |
105 | 120 | ||
106 | hasPlaylist () { | 121 | hasPlaylist () { |
107 | return !!this.playlist | 122 | return !!this.playlist |
108 | } | 123 | } |
109 | 124 | ||
110 | private getOptions (baseUrl?: string) { | 125 | private getPlaylistOptions (baseUrl?: string) { |
126 | return { | ||
127 | baseUrl, | ||
128 | |||
129 | playlistPosition: this.playlistPosition || undefined | ||
130 | } | ||
131 | } | ||
132 | |||
133 | private getVideoOptions (baseUrl?: string) { | ||
111 | return { | 134 | return { |
112 | baseUrl, | 135 | baseUrl, |
113 | 136 | ||