diff options
author | Chocobozzz <me@florianbigard.com> | 2020-05-12 10:32:56 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-05-12 10:32:56 +0200 |
commit | 3e2bc4ea4955ee452d742647683b9021d6b4d6d5 (patch) | |
tree | a18736a735cbbf4da2244e713c223d7def8a015c /client/src/assets/player/peertube-player-manager.ts | |
parent | 1d05f9bbea70af55ba23679d2db177aefb21f2e7 (diff) | |
download | PeerTube-3e2bc4ea4955ee452d742647683b9021d6b4d6d5.tar.gz PeerTube-3e2bc4ea4955ee452d742647683b9021d6b4d6d5.tar.zst PeerTube-3e2bc4ea4955ee452d742647683b9021d6b4d6d5.zip |
Fix webtorrent play on Safari
Diffstat (limited to 'client/src/assets/player/peertube-player-manager.ts')
-rw-r--r-- | client/src/assets/player/peertube-player-manager.ts | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/client/src/assets/player/peertube-player-manager.ts b/client/src/assets/player/peertube-player-manager.ts index 5ebc247f2..ebb1e454a 100644 --- a/client/src/assets/player/peertube-player-manager.ts +++ b/client/src/assets/player/peertube-player-manager.ts | |||
@@ -1,5 +1,3 @@ | |||
1 | import { VideoFile } from '../../../../shared/models/videos' | ||
2 | import videojs from 'video.js' | ||
3 | import 'videojs-hotkeys/videojs.hotkeys' | 1 | import 'videojs-hotkeys/videojs.hotkeys' |
4 | import 'videojs-dock' | 2 | import 'videojs-dock' |
5 | import 'videojs-contextmenu-ui' | 3 | import 'videojs-contextmenu-ui' |
@@ -20,14 +18,16 @@ import './videojs-components/settings-menu-item' | |||
20 | import './videojs-components/settings-panel' | 18 | import './videojs-components/settings-panel' |
21 | import './videojs-components/settings-panel-child' | 19 | import './videojs-components/settings-panel-child' |
22 | import './videojs-components/theater-button' | 20 | import './videojs-components/theater-button' |
23 | import { P2PMediaLoaderPluginOptions, UserWatching, VideoJSCaption, VideoJSPluginOptions } from './peertube-videojs-typings' | 21 | import videojs from 'video.js' |
24 | import { buildVideoEmbed, buildVideoLink, copyToClipboard, getRtcConfig } from './utils' | ||
25 | import { isDefaultLocale } from '../../../../shared/models/i18n/i18n' | 22 | import { isDefaultLocale } from '../../../../shared/models/i18n/i18n' |
26 | import { segmentValidatorFactory } from './p2p-media-loader/segment-validator' | 23 | import { VideoFile } from '../../../../shared/models/videos' |
27 | import { segmentUrlBuilderFactory } from './p2p-media-loader/segment-url-builder' | ||
28 | import { RedundancyUrlManager } from './p2p-media-loader/redundancy-url-manager' | 24 | import { RedundancyUrlManager } from './p2p-media-loader/redundancy-url-manager' |
25 | import { segmentUrlBuilderFactory } from './p2p-media-loader/segment-url-builder' | ||
26 | import { segmentValidatorFactory } from './p2p-media-loader/segment-validator' | ||
29 | import { getStoredP2PEnabled } from './peertube-player-local-storage' | 27 | import { getStoredP2PEnabled } from './peertube-player-local-storage' |
28 | import { P2PMediaLoaderPluginOptions, UserWatching, VideoJSCaption, VideoJSPluginOptions } from './peertube-videojs-typings' | ||
30 | import { TranslationsManager } from './translations-manager' | 29 | import { TranslationsManager } from './translations-manager' |
30 | import { buildVideoEmbed, buildVideoLink, copyToClipboard, getRtcConfig, isIOS, isSafari } from './utils' | ||
31 | 31 | ||
32 | // Change 'Playback Rate' to 'Speed' (smaller for our settings menu) | 32 | // Change 'Playback Rate' to 'Speed' (smaller for our settings menu) |
33 | (videojs.getComponent('PlaybackRateMenuButton') as any).prototype.controlText_ = 'Speed' | 33 | (videojs.getComponent('PlaybackRateMenuButton') as any).prototype.controlText_ = 'Speed' |
@@ -511,15 +511,12 @@ export class PeertubePlayerManager { | |||
511 | private static getAutoPlayValue (autoplay: any) { | 511 | private static getAutoPlayValue (autoplay: any) { |
512 | if (autoplay !== true) return autoplay | 512 | if (autoplay !== true) return autoplay |
513 | 513 | ||
514 | const isIOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform) | ||
515 | const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent) | ||
516 | |||
517 | // Giving up with iOS | 514 | // Giving up with iOS |
518 | if (isIOS) return false | 515 | if (isIOS()) return false |
519 | 516 | ||
520 | // We have issues with autoplay and Safari. | 517 | // We have issues with autoplay and Safari. |
521 | // any that tries to play using auto mute seems to work | 518 | // any that tries to play using auto mute seems to work |
522 | if (isSafari) return 'any' | 519 | if (isSafari()) return 'any' |
523 | 520 | ||
524 | return 'play' | 521 | return 'play' |
525 | } | 522 | } |