From d1bd87e066633b8a66266b280327ec828980916b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 22 May 2018 16:02:29 +0200 Subject: Make it works with new autoplay policy --- client/src/assets/player/peertube-player.ts | 16 ---------------- client/src/assets/player/peertube-videojs-plugin.ts | 14 ++++++++++++-- client/src/assets/player/utils.ts | 5 +++++ 3 files changed, 17 insertions(+), 18 deletions(-) (limited to 'client/src/assets') diff --git a/client/src/assets/player/peertube-player.ts b/client/src/assets/player/peertube-player.ts index 2e77a973f..f419d58fc 100644 --- a/client/src/assets/player/peertube-player.ts +++ b/client/src/assets/player/peertube-player.ts @@ -1,21 +1,5 @@ import { VideoFile } from '../../../../shared/models/videos' -import 'core-js/es6/symbol'; -import 'core-js/es6/object'; -import 'core-js/es6/function'; -import 'core-js/es6/parse-int'; -import 'core-js/es6/parse-float'; -import 'core-js/es6/number'; -import 'core-js/es6/math'; -import 'core-js/es6/string'; -import 'core-js/es6/date'; -import 'core-js/es6/array'; -import 'core-js/es6/regexp'; -import 'core-js/es6/map'; -import 'core-js/es6/weak-map'; -import 'core-js/es6/set'; -import 'core-js/es7/object'; - import 'videojs-hotkeys' import 'videojs-dock' import './peertube-link-button' diff --git a/client/src/assets/player/peertube-videojs-plugin.ts b/client/src/assets/player/peertube-videojs-plugin.ts index 5789641fe..1e68100d1 100644 --- a/client/src/assets/player/peertube-videojs-plugin.ts +++ b/client/src/assets/player/peertube-videojs-plugin.ts @@ -4,7 +4,15 @@ import { VideoFile } from '../../../../shared/models/videos/video.model' import { renderVideo } from './video-renderer' import './settings-menu-button' import { PeertubePluginOptions, VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' -import { getAverageBandwidth, getStoredMute, getStoredVolume, saveAverageBandwidth, saveMuteInStore, saveVolumeInStore } from './utils' +import { + getAverageBandwidth, + getStoredMute, + getStoredVolume, + isMobile, + saveAverageBandwidth, + saveMuteInStore, + saveVolumeInStore +} from './utils' import minBy from 'lodash-es/minBy' import maxBy from 'lodash-es/maxBy' import * as CacheChunkStore from 'cache-chunk-store' @@ -262,7 +270,6 @@ class PeerTubePlugin extends Plugin { private tryToPlay (done?: Function) { if (!done) done = function () { /* empty */ } - const playPromise = this.player.play() if (playPromise !== undefined) { return playPromise.then(done) @@ -348,6 +355,9 @@ class PeerTubePlugin extends Plugin { // Proxy first play const oldPlay = this.player.play.bind(this.player) this.player.play = () => { + // Avoid issue new play policy on mobiles + if (isMobile()) oldPlay() + this.player.addClass('vjs-has-big-play-button-clicked') this.player.play = oldPlay diff --git a/client/src/assets/player/utils.ts b/client/src/assets/player/utils.ts index f5407ef60..1df39d4e4 100644 --- a/client/src/assets/player/utils.ts +++ b/client/src/assets/player/utils.ts @@ -60,6 +60,10 @@ function saveAverageBandwidth (value: number) { return setLocalStorage('average-bandwidth', value.toString()) } +function isMobile () { + return /iPhone|iPad|iPod|Android/i.test(navigator.userAgent) +} + export { toTitleCase, getStoredVolume, @@ -68,6 +72,7 @@ export { getAverageBandwidth, saveMuteInStore, getStoredMute, + isMobile, bytes } -- cgit v1.2.3