diff options
Diffstat (limited to 'client/src/assets/player/peertube-player-manager.ts')
-rw-r--r-- | client/src/assets/player/peertube-player-manager.ts | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/client/src/assets/player/peertube-player-manager.ts b/client/src/assets/player/peertube-player-manager.ts index 15b2f420b..4d72523f7 100644 --- a/client/src/assets/player/peertube-player-manager.ts +++ b/client/src/assets/player/peertube-player-manager.ts | |||
@@ -35,7 +35,7 @@ import { | |||
35 | VideoJSPluginOptions | 35 | VideoJSPluginOptions |
36 | } from './peertube-videojs-typings' | 36 | } from './peertube-videojs-typings' |
37 | import { TranslationsManager } from './translations-manager' | 37 | import { TranslationsManager } from './translations-manager' |
38 | import { buildVideoOrPlaylistEmbed, buildVideoLink, copyToClipboard, getRtcConfig, isIOS, isSafari } from './utils' | 38 | import { buildVideoOrPlaylistEmbed, buildVideoLink, copyToClipboard, getRtcConfig, isSafari, isIOS } from './utils' |
39 | 39 | ||
40 | // Change 'Playback Rate' to 'Speed' (smaller for our settings menu) | 40 | // Change 'Playback Rate' to 'Speed' (smaller for our settings menu) |
41 | (videojs.getComponent('PlaybackRateMenuButton') as any).prototype.controlText_ = 'Speed' | 41 | (videojs.getComponent('PlaybackRateMenuButton') as any).prototype.controlText_ = 'Speed' |
@@ -117,6 +117,8 @@ export class PeertubePlayerManager { | |||
117 | private static playerElementClassName: string | 117 | private static playerElementClassName: string |
118 | private static onPlayerChange: (player: videojs.Player) => void | 118 | private static onPlayerChange: (player: videojs.Player) => void |
119 | 119 | ||
120 | private static alreadyPlayed = false | ||
121 | |||
120 | static async initialize (mode: PlayerMode, options: PeertubePlayerManagerOptions, onPlayerChange: (player: videojs.Player) => void) { | 122 | static async initialize (mode: PlayerMode, options: PeertubePlayerManagerOptions, onPlayerChange: (player: videojs.Player) => void) { |
121 | let p2pMediaLoader: any | 123 | let p2pMediaLoader: any |
122 | 124 | ||
@@ -152,6 +154,10 @@ export class PeertubePlayerManager { | |||
152 | alreadyFallback = true | 154 | alreadyFallback = true |
153 | }) | 155 | }) |
154 | 156 | ||
157 | player.one('play', () => { | ||
158 | PeertubePlayerManager.alreadyPlayed = true | ||
159 | }) | ||
160 | |||
155 | self.addContextMenu(mode, player, options.common.embedUrl) | 161 | self.addContextMenu(mode, player, options.common.embedUrl) |
156 | 162 | ||
157 | player.bezels() | 163 | player.bezels() |
@@ -202,6 +208,7 @@ export class PeertubePlayerManager { | |||
202 | p2pMediaLoaderModule?: any | 208 | p2pMediaLoaderModule?: any |
203 | ): videojs.PlayerOptions { | 209 | ): videojs.PlayerOptions { |
204 | const commonOptions = options.common | 210 | const commonOptions = options.common |
211 | const isHLS = mode === 'p2p-media-loader' | ||
205 | 212 | ||
206 | let autoplay = this.getAutoPlayValue(commonOptions.autoplay) | 213 | let autoplay = this.getAutoPlayValue(commonOptions.autoplay) |
207 | let html5 = {} | 214 | let html5 = {} |
@@ -227,7 +234,7 @@ export class PeertubePlayerManager { | |||
227 | PeertubePlayerManager.addHotkeysOptions(plugins) | 234 | PeertubePlayerManager.addHotkeysOptions(plugins) |
228 | } | 235 | } |
229 | 236 | ||
230 | if (mode === 'p2p-media-loader') { | 237 | if (isHLS) { |
231 | const { hlsjs } = PeertubePlayerManager.addP2PMediaLoaderOptions(plugins, options, p2pMediaLoaderModule) | 238 | const { hlsjs } = PeertubePlayerManager.addP2PMediaLoaderOptions(plugins, options, p2pMediaLoaderModule) |
232 | 239 | ||
233 | html5 = hlsjs.html5 | 240 | html5 = hlsjs.html5 |
@@ -358,8 +365,12 @@ export class PeertubePlayerManager { | |||
358 | const commonOptions = options.common | 365 | const commonOptions = options.common |
359 | const webtorrentOptions = options.webtorrent | 366 | const webtorrentOptions = options.webtorrent |
360 | 367 | ||
368 | const autoplay = this.getAutoPlayValue(commonOptions.autoplay) === 'play' | ||
369 | ? true | ||
370 | : false | ||
371 | |||
361 | const webtorrent = { | 372 | const webtorrent = { |
362 | autoplay: commonOptions.autoplay, | 373 | autoplay, |
363 | videoDuration: commonOptions.videoDuration, | 374 | videoDuration: commonOptions.videoDuration, |
364 | playerElement: commonOptions.playerElement, | 375 | playerElement: commonOptions.playerElement, |
365 | videoFiles: webtorrentOptions.videoFiles, | 376 | videoFiles: webtorrentOptions.videoFiles, |
@@ -579,12 +590,11 @@ export class PeertubePlayerManager { | |||
579 | private static getAutoPlayValue (autoplay: any) { | 590 | private static getAutoPlayValue (autoplay: any) { |
580 | if (autoplay !== true) return autoplay | 591 | if (autoplay !== true) return autoplay |
581 | 592 | ||
582 | // Giving up with iOS | 593 | // On first play, disable autoplay to avoid issues |
583 | if (isIOS()) return false | 594 | // But if the player already played videos, we can safely autoplay next ones |
584 | 595 | if (isIOS() || isSafari()) { | |
585 | // We have issues with autoplay and Safari. | 596 | return PeertubePlayerManager.alreadyPlayed ? 'play' : false |
586 | // any that tries to play using auto mute seems to work | 597 | } |
587 | if (isSafari()) return 'any' | ||
588 | 598 | ||
589 | return 'play' | 599 | return 'play' |
590 | } | 600 | } |