X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fassets%2Fplayer%2Fpeertube-player-manager.ts;h=8e0a9109f6c41d8bf0cdfb1020a607c273b38941;hb=9eccae74c844f09e9e3483db623fea00e0562365;hp=c71b4341554307e793e0410e4b23bf4e5efd4dd5;hpb=a950e4c82bd458e924b00698a77c06275a64a46c;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/assets/player/peertube-player-manager.ts b/client/src/assets/player/peertube-player-manager.ts index c71b43415..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 { VideoJSPluginOptions } from './peertube-videojs-typings' import { TranslationsManager } from './translations-manager' -import { buildVideoEmbed, buildVideoLink, copyToClipboard, getRtcConfig, isIOS, isSafari } from './utils' +import { buildVideoOrPlaylistEmbed, buildVideoLink, copyToClipboard, getRtcConfig, isSafari, isIOS } from './utils' // Change 'Playback Rate' to 'Speed' (smaller for our settings menu) (videojs.getComponent('PlaybackRateMenuButton') as any).prototype.controlText_ = 'Speed' @@ -117,6 +117,8 @@ export class PeertubePlayerManager { private static playerElementClassName: string private static onPlayerChange: (player: videojs.Player) => void + private static alreadyPlayed = false + static async initialize (mode: PlayerMode, options: PeertubePlayerManagerOptions, onPlayerChange: (player: videojs.Player) => void) { let p2pMediaLoader: any @@ -152,6 +154,10 @@ export class PeertubePlayerManager { alreadyFallback = true }) + player.one('play', () => { + PeertubePlayerManager.alreadyPlayed = true + }) + self.addContextMenu(mode, player, options.common.embedUrl) player.bezels() @@ -202,6 +208,7 @@ export class PeertubePlayerManager { p2pMediaLoaderModule?: any ): videojs.PlayerOptions { const commonOptions = options.common + const isHLS = mode === 'p2p-media-loader' let autoplay = this.getAutoPlayValue(commonOptions.autoplay) let html5 = {} @@ -227,7 +234,7 @@ export class PeertubePlayerManager { PeertubePlayerManager.addHotkeysOptions(plugins) } - if (mode === 'p2p-media-loader') { + if (isHLS) { const { hlsjs } = PeertubePlayerManager.addP2PMediaLoaderOptions(plugins, options, p2pMediaLoaderModule) html5 = hlsjs.html5 @@ -492,7 +499,7 @@ export class PeertubePlayerManager { { label: player.localize('Copy embed code'), listener: () => { - copyToClipboard(buildVideoEmbed(videoEmbedUrl)) + copyToClipboard(buildVideoOrPlaylistEmbed(videoEmbedUrl)) } } ] @@ -579,12 +586,15 @@ export class PeertubePlayerManager { private static getAutoPlayValue (autoplay: any) { if (autoplay !== true) return autoplay - // Giving up with iOS - if (isIOS()) return false - - // We have issues with autoplay and Safari. - // any that tries to play using auto mute seems to work - if (isSafari()) return 'any' + // We have issues with autoplay and Safari with webtorrent + if (isIOS()) { + // On first play, disable autoplay to avoid issues + // But if the player already played videos, we can safely autoplay next ones + return PeertubePlayerManager.alreadyPlayed ? 'play' : false + } else if (isSafari()) { + // Issues with Safari and webtorrent on first play + return PeertubePlayerManager.alreadyPlayed ? 'play' : false + } return 'play' }