aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/utils.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-06-12 12:40:24 +0200
committerChocobozzz <me@florianbigard.com>2019-06-12 16:44:15 +0200
commit2f4c784a92ac50cacef07f4925e284b4041422f4 (patch)
tree159e744c68c5f5cd8054b5f63eb389553e13bf56 /client/src/assets/player/utils.ts
parent011e1e6b37e15a44624b2d0e50263e16382060d2 (diff)
downloadPeerTube-2f4c784a92ac50cacef07f4925e284b4041422f4.tar.gz
PeerTube-2f4c784a92ac50cacef07f4925e284b4041422f4.tar.zst
PeerTube-2f4c784a92ac50cacef07f4925e284b4041422f4.zip
Add params to share modal
Diffstat (limited to 'client/src/assets/player/utils.ts')
-rw-r--r--client/src/assets/player/utils.ts51
1 files changed, 44 insertions, 7 deletions
diff --git a/client/src/assets/player/utils.ts b/client/src/assets/player/utils.ts
index 366689962..777abb568 100644
--- a/client/src/assets/player/utils.ts
+++ b/client/src/assets/player/utils.ts
@@ -27,18 +27,55 @@ function isMobile () {
27 return /iPhone|iPad|iPod|Android/i.test(navigator.userAgent) 27 return /iPhone|iPad|iPod|Android/i.test(navigator.userAgent)
28} 28}
29 29
30function buildVideoLink (time?: number, url?: string) { 30function buildVideoLink (options: {
31 if (!url) url = window.location.origin + window.location.pathname.replace('/embed/', '/watch/') 31 baseUrl?: string,
32 32
33 if (time) { 33 startTime?: number,
34 const timeInt = Math.floor(time) 34 stopTime?: number,
35 35
36 const params = new URLSearchParams(window.location.search) 36 subtitle?: string,
37 params.set('start', secondsToTime(timeInt))
38 37
39 return url + '?' + params.toString() 38 loop?: boolean,
39 autoplay?: boolean,
40 muted?: boolean,
41
42 // Embed options
43 title?: boolean,
44 warningTitle?: boolean,
45 controls?: boolean
46} = {}) {
47 const { baseUrl } = options
48
49 const url = baseUrl
50 ? baseUrl
51 : window.location.origin + window.location.pathname.replace('/embed/', '/watch/')
52
53 const params = new URLSearchParams(window.location.search)
54
55 if (options.startTime) {
56 const startTimeInt = Math.floor(options.startTime)
57 params.set('start', secondsToTime(startTimeInt))
58 }
59
60 if (options.stopTime) {
61 const stopTimeInt = Math.floor(options.stopTime)
62 params.set('stop', secondsToTime(stopTimeInt))
40 } 63 }
41 64
65 if (options.subtitle) params.set('subtitle', options.subtitle)
66
67 if (options.loop === true) params.set('loop', '1')
68 if (options.autoplay === true) params.set('autoplay', '1')
69 if (options.muted === true) params.set('muted', '1')
70 if (options.title === false) params.set('title', '0')
71 if (options.warningTitle === false) params.set('warningTitle', '0')
72 if (options.controls === false) params.set('controls', '0')
73
74 let hasParams = false
75 params.forEach(() => hasParams = true)
76
77 if (hasParams) return url + '?' + params.toString()
78
42 return url 79 return url
43} 80}
44 81