aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/assets')
-rw-r--r--client/src/assets/images/global/add.html6
-rw-r--r--client/src/assets/images/video/playlist-add.html10
-rw-r--r--client/src/assets/images/video/watch-later.html11
-rw-r--r--client/src/assets/player/peertube-player-manager.ts9
-rw-r--r--client/src/assets/player/peertube-plugin.ts16
-rw-r--r--client/src/assets/player/peertube-videojs-typings.ts7
-rw-r--r--client/src/assets/player/utils.ts20
-rw-r--r--client/src/assets/player/webtorrent/webtorrent-plugin.ts4
8 files changed, 63 insertions, 20 deletions
diff --git a/client/src/assets/images/global/add.html b/client/src/assets/images/global/add.html
index bfb0a52bc..34f497056 100644
--- a/client/src/assets/images/global/add.html
+++ b/client/src/assets/images/global/add.html
@@ -2,9 +2,9 @@
2 <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"> 2 <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
3 <g transform="translate(-92.000000, -115.000000)"> 3 <g transform="translate(-92.000000, -115.000000)">
4 <g id="2" transform="translate(92.000000, 115.000000)"> 4 <g id="2" transform="translate(92.000000, 115.000000)">
5 <circle id="Oval-1" stroke="#ffffff" stroke-width="2" cx="12" cy="12" r="10"></circle> 5 <circle id="Oval-1" stroke="#000000" stroke-width="2" cx="12" cy="12" r="10"></circle>
6 <rect id="Rectangle-1" fill="#ffffff" x="11" y="7" width="2" height="10" rx="1"></rect> 6 <rect id="Rectangle-1" fill="#000000" x="11" y="7" width="2" height="10" rx="1"></rect>
7 <rect id="Rectangle-1" fill="#ffffff" x="7" y="11" width="10" height="2" rx="1"></rect> 7 <rect id="Rectangle-1" fill="#000000" x="7" y="11" width="10" height="2" rx="1"></rect>
8 </g> 8 </g>
9 </g> 9 </g>
10 </g> 10 </g>
diff --git a/client/src/assets/images/video/playlist-add.html b/client/src/assets/images/video/playlist-add.html
new file mode 100644
index 000000000..ada845c75
--- /dev/null
+++ b/client/src/assets/images/video/playlist-add.html
@@ -0,0 +1,10 @@
1<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
2 viewBox="0 0 426.667 426.667" xml:space="preserve">
3 <g fill="#000000">
4 <rect x="0" y="64" width="256" height="42.667"/>
5 <rect x="0" y="149.333" width="256" height="42.667"/>
6 <rect x="0" y="234.667" width="170.667" height="42.667"/>
7 <polygon points="341.333,234.667 341.333,149.333 298.667,149.333 298.667,234.667 213.333,234.667 213.333,277.333
8 298.667,277.333 298.667,362.667 341.333,362.667 341.333,277.333 426.667,277.333 426.667,234.667 "/>
9 </g>
10</svg>
diff --git a/client/src/assets/images/video/watch-later.html b/client/src/assets/images/video/watch-later.html
new file mode 100644
index 000000000..927afebe4
--- /dev/null
+++ b/client/src/assets/images/video/watch-later.html
@@ -0,0 +1,11 @@
1<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 80 100"
2 enable-background="new 0 0 80 80" xml:space="preserve"><g><path fill="#000000" d="M33.3,51.5L33.3,51.5c-1.8,0-3.3-1.4-3.3-3.1V37.3c0-1.7,1.5-3.1,3.3-3.1c0.5,0,1,0.1,1.5,0.4l10.7,5.5 c1,0.5,1.6,1.5,1.6,2.7c0,1.2-0.6,2.2-1.7,2.8l-10.6,5.6C34.3,51.3,33.8,51.5,33.3,51.5z M33.3,36.2c-0.6,0-1.3,0.4-1.3,1.1v11.1 c0,0.6,0.7,1.1,1.3,1.1l0,0c0.2,0,0.4,0,0.5-0.1l10.6-5.6c0.4-0.2,0.6-0.6,0.6-1c0-0.2-0.1-0.6-0.5-0.9l-10.7-5.5 C33.6,36.2,33.4,36.2,33.3,36.2z"/></g>
3 <g><path fill="#000000" d="M62.9,65H12.1C10.4,65,9,63.6,9,61.9V22.1c0-1.7,1.4-3.1,3.1-3.1h50.8c1.7,0,3.1,1.4,3.1,3.1v39.8 C66,63.6,64.6,65,62.9,65z M12.1,21c-0.6,0-1.1,0.5-1.1,1.1v39.8c0,0.6,0.5,1.1,1.1,1.1h50.8c0.6,0,1.1-0.5,1.1-1.1V22.1 c0-0.6-0.5-1.1-1.1-1.1H12.1z"/></g>
4 <g><path fill="#000000" d="M63,16h-2c0-1-0.4-1-0.9-1H14.9c-0.5,0-0.9,0-0.9,1h-2c0-2,1.3-3,2.9-3h45.3C61.7,13,63,14,63,16z"/></g>
5 <g><path fill="#000000" d="M58,11h-2c0-1-0.4-1-0.5-1H19.5c-0.1,0-0.5,0-0.5,1h-2c0-2,1.1-3,2.5-3h36.1C56.9,8,58,9,58,11z"/></g>
6 <g><path fill="#000000" d="M68,29v-2c4,0,6.5-2.9,6.5-6.5S72,14,68,14v-2c5,0,8.5,3.8,8.5,8.5S73,29,68,29z"/></g>
7 <g><polygon fill="#000000" points="71.3,18.7 65.6,13 71.3,7.3 72.7,8.7 68.4,13 72.7,17.3 "/></g>
8 <text x="0" y="95" fill="#000000" font-size="5px" font-weight="bold"
9 font-family="'Helvetica Neue', Helvetica, Arial-Unicode, Arial, Sans-serif">Created by Yaroslav Samoylov</text>
10 <text x="0" y="100" fill="#000000" font-size="5px" font-weight="bold"
11 font-family="'Helvetica Neue', Helvetica, Arial-Unicode, Arial, Sans-serif">from the Noun Project</text></svg>
diff --git a/client/src/assets/player/peertube-player-manager.ts b/client/src/assets/player/peertube-player-manager.ts
index 7631d095f..6cdd54372 100644
--- a/client/src/assets/player/peertube-player-manager.ts
+++ b/client/src/assets/player/peertube-player-manager.ts
@@ -49,6 +49,7 @@ export type CommonOptions = {
49 inactivityTimeout: number 49 inactivityTimeout: number
50 poster: string 50 poster: string
51 startTime: number | string 51 startTime: number | string
52 stopTime: number | string
52 53
53 theaterMode: boolean 54 theaterMode: boolean
54 captions: boolean 55 captions: boolean
@@ -199,10 +200,10 @@ export class PeertubePlayerManager {
199 autoplay, // Use peertube plugin autoplay because we get the file by webtorrent 200 autoplay, // Use peertube plugin autoplay because we get the file by webtorrent
200 videoViewUrl: commonOptions.videoViewUrl, 201 videoViewUrl: commonOptions.videoViewUrl,
201 videoDuration: commonOptions.videoDuration, 202 videoDuration: commonOptions.videoDuration,
202 startTime: commonOptions.startTime,
203 userWatching: commonOptions.userWatching, 203 userWatching: commonOptions.userWatching,
204 subtitle: commonOptions.subtitle, 204 subtitle: commonOptions.subtitle,
205 videoCaptions: commonOptions.videoCaptions 205 videoCaptions: commonOptions.videoCaptions,
206 stopTime: commonOptions.stopTime
206 } 207 }
207 } 208 }
208 209
@@ -210,6 +211,7 @@ export class PeertubePlayerManager {
210 const p2pMediaLoader: P2PMediaLoaderPluginOptions = { 211 const p2pMediaLoader: P2PMediaLoaderPluginOptions = {
211 redundancyBaseUrls: options.p2pMediaLoader.redundancyBaseUrls, 212 redundancyBaseUrls: options.p2pMediaLoader.redundancyBaseUrls,
212 type: 'application/x-mpegURL', 213 type: 'application/x-mpegURL',
214 startTime: commonOptions.startTime,
213 src: p2pMediaLoaderOptions.playlistUrl 215 src: p2pMediaLoaderOptions.playlistUrl
214 } 216 }
215 217
@@ -254,7 +256,8 @@ export class PeertubePlayerManager {
254 autoplay, 256 autoplay,
255 videoDuration: commonOptions.videoDuration, 257 videoDuration: commonOptions.videoDuration,
256 playerElement: commonOptions.playerElement, 258 playerElement: commonOptions.playerElement,
257 videoFiles: webtorrentOptions.videoFiles 259 videoFiles: webtorrentOptions.videoFiles,
260 startTime: commonOptions.startTime
258 } 261 }
259 Object.assign(plugins, { webtorrent }) 262 Object.assign(plugins, { webtorrent })
260 263
diff --git a/client/src/assets/player/peertube-plugin.ts b/client/src/assets/player/peertube-plugin.ts
index 92ac57cf5..3991e4627 100644
--- a/client/src/assets/player/peertube-plugin.ts
+++ b/client/src/assets/player/peertube-plugin.ts
@@ -22,7 +22,6 @@ import {
22 22
23const Plugin: VideoJSComponentInterface = videojs.getPlugin('plugin') 23const Plugin: VideoJSComponentInterface = videojs.getPlugin('plugin')
24class PeerTubePlugin extends Plugin { 24class PeerTubePlugin extends Plugin {
25 private readonly startTime: number = 0
26 private readonly videoViewUrl: string 25 private readonly videoViewUrl: string
27 private readonly videoDuration: number 26 private readonly videoDuration: number
28 private readonly CONSTANTS = { 27 private readonly CONSTANTS = {
@@ -35,13 +34,11 @@ class PeerTubePlugin extends Plugin {
35 34
36 private videoViewInterval: any 35 private videoViewInterval: any
37 private userWatchingVideoInterval: any 36 private userWatchingVideoInterval: any
38 private qualityObservationTimer: any
39 private lastResolutionChange: ResolutionUpdateData 37 private lastResolutionChange: ResolutionUpdateData
40 38
41 constructor (player: videojs.Player, options: PeerTubePluginOptions) { 39 constructor (player: videojs.Player, options: PeerTubePluginOptions) {
42 super(player, options) 40 super(player, options)
43 41
44 this.startTime = timeToInt(options.startTime)
45 this.videoViewUrl = options.videoViewUrl 42 this.videoViewUrl = options.videoViewUrl
46 this.videoDuration = options.videoDuration 43 this.videoDuration = options.videoDuration
47 this.videoCaptions = options.videoCaptions 44 this.videoCaptions = options.videoCaptions
@@ -84,6 +81,14 @@ class PeerTubePlugin extends Plugin {
84 saveMuteInStore(this.player.muted()) 81 saveMuteInStore(this.player.muted())
85 }) 82 })
86 83
84 if (options.stopTime) {
85 const stopTime = timeToInt(options.stopTime)
86
87 this.player.on('timeupdate', () => {
88 if (this.player.currentTime() > stopTime) this.player.pause()
89 })
90 }
91
87 this.player.textTracks().on('change', () => { 92 this.player.textTracks().on('change', () => {
88 const showing = this.player.textTracks().tracks_.find((t: { kind: string, mode: string }) => { 93 const showing = this.player.textTracks().tracks_.find((t: { kind: string, mode: string }) => {
89 return t.kind === 'captions' && t.mode === 'showing' 94 return t.kind === 'captions' && t.mode === 'showing'
@@ -109,10 +114,7 @@ class PeerTubePlugin extends Plugin {
109 } 114 }
110 115
111 dispose () { 116 dispose () {
112 clearTimeout(this.qualityObservationTimer) 117 if (this.videoViewInterval) clearInterval(this.videoViewInterval)
113
114 clearInterval(this.videoViewInterval)
115
116 if (this.userWatchingVideoInterval) clearInterval(this.userWatchingVideoInterval) 118 if (this.userWatchingVideoInterval) clearInterval(this.userWatchingVideoInterval)
117 } 119 }
118 120
diff --git a/client/src/assets/player/peertube-videojs-typings.ts b/client/src/assets/player/peertube-videojs-typings.ts
index 79a5a6c4d..a96b0bc8c 100644
--- a/client/src/assets/player/peertube-videojs-typings.ts
+++ b/client/src/assets/player/peertube-videojs-typings.ts
@@ -41,12 +41,13 @@ type PeerTubePluginOptions = {
41 autoplay: boolean 41 autoplay: boolean
42 videoViewUrl: string 42 videoViewUrl: string
43 videoDuration: number 43 videoDuration: number
44 startTime: number | string
45 44
46 userWatching?: UserWatching 45 userWatching?: UserWatching
47 subtitle?: string 46 subtitle?: string
48 47
49 videoCaptions: VideoJSCaption[] 48 videoCaptions: VideoJSCaption[]
49
50 stopTime: number | string
50} 51}
51 52
52type WebtorrentPluginOptions = { 53type WebtorrentPluginOptions = {
@@ -56,12 +57,16 @@ type WebtorrentPluginOptions = {
56 videoDuration: number 57 videoDuration: number
57 58
58 videoFiles: VideoFile[] 59 videoFiles: VideoFile[]
60
61 startTime: number | string
59} 62}
60 63
61type P2PMediaLoaderPluginOptions = { 64type P2PMediaLoaderPluginOptions = {
62 redundancyBaseUrls: string[] 65 redundancyBaseUrls: string[]
63 type: string 66 type: string
64 src: string 67 src: string
68
69 startTime: number | string
65} 70}
66 71
67type VideoJSPluginOptions = { 72type VideoJSPluginOptions = {
diff --git a/client/src/assets/player/utils.ts b/client/src/assets/player/utils.ts
index 8d87567c2..54f131310 100644
--- a/client/src/assets/player/utils.ts
+++ b/client/src/assets/player/utils.ts
@@ -42,7 +42,7 @@ function timeToInt (time: number | string) {
42 if (!time) return 0 42 if (!time) return 0
43 if (typeof time === 'number') return time 43 if (typeof time === 'number') return time
44 44
45 const reg = /^((\d+)h)?((\d+)m)?((\d+)s?)?$/ 45 const reg = /^((\d+)[h:])?((\d+)[m:])?((\d+)s?)?$/
46 const matches = time.match(reg) 46 const matches = time.match(reg)
47 47
48 if (!matches) return 0 48 if (!matches) return 0
@@ -54,18 +54,27 @@ function timeToInt (time: number | string) {
54 return hours * 3600 + minutes * 60 + seconds 54 return hours * 3600 + minutes * 60 + seconds
55} 55}
56 56
57function secondsToTime (seconds: number) { 57function secondsToTime (seconds: number, full = false, symbol?: string) {
58 let time = '' 58 let time = ''
59 59
60 const hourSymbol = (symbol || 'h')
61 const minuteSymbol = (symbol || 'm')
62 const secondsSymbol = full ? '' : 's'
63
60 let hours = Math.floor(seconds / 3600) 64 let hours = Math.floor(seconds / 3600)
61 if (hours >= 1) time = hours + 'h' 65 if (hours >= 1) time = hours + hourSymbol
66 else if (full) time = '0' + hourSymbol
62 67
63 seconds %= 3600 68 seconds %= 3600
64 let minutes = Math.floor(seconds / 60) 69 let minutes = Math.floor(seconds / 60)
65 if (minutes >= 1) time += minutes + 'm' 70 if (minutes >= 1 && minutes < 10 && full) time += '0' + minutes + minuteSymbol
71 else if (minutes >= 1) time += minutes + minuteSymbol
72 else if (full) time += '00' + minuteSymbol
66 73
67 seconds %= 60 74 seconds %= 60
68 if (seconds >= 1) time += seconds + 's' 75 if (seconds >= 1 && seconds < 10 && full) time += '0' + seconds + secondsSymbol
76 else if (seconds >= 1) time += seconds + secondsSymbol
77 else if (full) time += '00'
69 78
70 return time 79 return time
71} 80}
@@ -131,6 +140,7 @@ export {
131 getRtcConfig, 140 getRtcConfig,
132 toTitleCase, 141 toTitleCase,
133 timeToInt, 142 timeToInt,
143 secondsToTime,
134 buildVideoLink, 144 buildVideoLink,
135 buildVideoEmbed, 145 buildVideoEmbed,
136 videoFileMaxByResolution, 146 videoFileMaxByResolution,
diff --git a/client/src/assets/player/webtorrent/webtorrent-plugin.ts b/client/src/assets/player/webtorrent/webtorrent-plugin.ts
index c69bf31fa..c7182acc9 100644
--- a/client/src/assets/player/webtorrent/webtorrent-plugin.ts
+++ b/client/src/assets/player/webtorrent/webtorrent-plugin.ts
@@ -6,7 +6,7 @@ import * as WebTorrent from 'webtorrent'
6import { VideoFile } from '../../../../../shared/models/videos/video.model' 6import { VideoFile } from '../../../../../shared/models/videos/video.model'
7import { renderVideo } from './video-renderer' 7import { renderVideo } from './video-renderer'
8import { LoadedQualityData, PlayerNetworkInfo, VideoJSComponentInterface, WebtorrentPluginOptions } from '../peertube-videojs-typings' 8import { LoadedQualityData, PlayerNetworkInfo, VideoJSComponentInterface, WebtorrentPluginOptions } from '../peertube-videojs-typings'
9import { getRtcConfig, videoFileMaxByResolution, videoFileMinByResolution } from '../utils' 9import { getRtcConfig, timeToInt, videoFileMaxByResolution, videoFileMinByResolution } from '../utils'
10import { PeertubeChunkStore } from './peertube-chunk-store' 10import { PeertubeChunkStore } from './peertube-chunk-store'
11import { 11import {
12 getAverageBandwidthInStore, 12 getAverageBandwidthInStore,
@@ -73,6 +73,8 @@ class WebTorrentPlugin extends Plugin {
73 constructor (player: videojs.Player, options: WebtorrentPluginOptions) { 73 constructor (player: videojs.Player, options: WebtorrentPluginOptions) {
74 super(player, options) 74 super(player, options)
75 75
76 this.startTime = timeToInt(options.startTime)
77
76 // Disable auto play on iOS 78 // Disable auto play on iOS
77 this.autoplay = options.autoplay && this.isIOS() === false 79 this.autoplay = options.autoplay && this.isIOS() === false
78 this.playerRefusedP2P = !getStoredWebTorrentEnabled() 80 this.playerRefusedP2P = !getStoredWebTorrentEnabled()