aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/peertube-player-manager.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/assets/player/peertube-player-manager.ts')
-rw-r--r--client/src/assets/player/peertube-player-manager.ts26
1 files changed, 18 insertions, 8 deletions
diff --git a/client/src/assets/player/peertube-player-manager.ts b/client/src/assets/player/peertube-player-manager.ts
index 15b2f420b..8e0a9109f 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'
37import { TranslationsManager } from './translations-manager' 37import { TranslationsManager } from './translations-manager'
38import { buildVideoOrPlaylistEmbed, buildVideoLink, copyToClipboard, getRtcConfig, isIOS, isSafari } from './utils' 38import { 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
@@ -579,12 +586,15 @@ export class PeertubePlayerManager {
579 private static getAutoPlayValue (autoplay: any) { 586 private static getAutoPlayValue (autoplay: any) {
580 if (autoplay !== true) return autoplay 587 if (autoplay !== true) return autoplay
581 588
582 // Giving up with iOS 589 // We have issues with autoplay and Safari with webtorrent
583 if (isIOS()) return false 590 if (isIOS()) {
584 591 // On first play, disable autoplay to avoid issues
585 // We have issues with autoplay and Safari. 592 // But if the player already played videos, we can safely autoplay next ones
586 // any that tries to play using auto mute seems to work 593 return PeertubePlayerManager.alreadyPlayed ? 'play' : false
587 if (isSafari()) return 'any' 594 } else if (isSafari()) {
595 // Issues with Safari and webtorrent on first play
596 return PeertubePlayerManager.alreadyPlayed ? 'play' : false
597 }
588 598
589 return 'play' 599 return 'play'
590 } 600 }