diff options
author | Chocobozzz <me@florianbigard.com> | 2018-05-22 16:02:29 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-05-22 16:02:29 +0200 |
commit | d1bd87e066633b8a66266b280327ec828980916b (patch) | |
tree | bfb30a565088cbb2675a8ab224b1ae1fc5dbfd16 /client/src/assets | |
parent | 293c885b5c6d4d694792cf430c51d73ecd1f3bee (diff) | |
download | PeerTube-d1bd87e066633b8a66266b280327ec828980916b.tar.gz PeerTube-d1bd87e066633b8a66266b280327ec828980916b.tar.zst PeerTube-d1bd87e066633b8a66266b280327ec828980916b.zip |
Make it works with new autoplay policy
Diffstat (limited to 'client/src/assets')
-rw-r--r-- | client/src/assets/player/peertube-player.ts | 16 | ||||
-rw-r--r-- | client/src/assets/player/peertube-videojs-plugin.ts | 14 | ||||
-rw-r--r-- | client/src/assets/player/utils.ts | 5 |
3 files changed, 17 insertions, 18 deletions
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 @@ | |||
1 | import { VideoFile } from '../../../../shared/models/videos' | 1 | import { VideoFile } from '../../../../shared/models/videos' |
2 | 2 | ||
3 | import 'core-js/es6/symbol'; | ||
4 | import 'core-js/es6/object'; | ||
5 | import 'core-js/es6/function'; | ||
6 | import 'core-js/es6/parse-int'; | ||
7 | import 'core-js/es6/parse-float'; | ||
8 | import 'core-js/es6/number'; | ||
9 | import 'core-js/es6/math'; | ||
10 | import 'core-js/es6/string'; | ||
11 | import 'core-js/es6/date'; | ||
12 | import 'core-js/es6/array'; | ||
13 | import 'core-js/es6/regexp'; | ||
14 | import 'core-js/es6/map'; | ||
15 | import 'core-js/es6/weak-map'; | ||
16 | import 'core-js/es6/set'; | ||
17 | import 'core-js/es7/object'; | ||
18 | |||
19 | import 'videojs-hotkeys' | 3 | import 'videojs-hotkeys' |
20 | import 'videojs-dock' | 4 | import 'videojs-dock' |
21 | import './peertube-link-button' | 5 | 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' | |||
4 | import { renderVideo } from './video-renderer' | 4 | import { renderVideo } from './video-renderer' |
5 | import './settings-menu-button' | 5 | import './settings-menu-button' |
6 | import { PeertubePluginOptions, VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' | 6 | import { PeertubePluginOptions, VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' |
7 | import { getAverageBandwidth, getStoredMute, getStoredVolume, saveAverageBandwidth, saveMuteInStore, saveVolumeInStore } from './utils' | 7 | import { |
8 | getAverageBandwidth, | ||
9 | getStoredMute, | ||
10 | getStoredVolume, | ||
11 | isMobile, | ||
12 | saveAverageBandwidth, | ||
13 | saveMuteInStore, | ||
14 | saveVolumeInStore | ||
15 | } from './utils' | ||
8 | import minBy from 'lodash-es/minBy' | 16 | import minBy from 'lodash-es/minBy' |
9 | import maxBy from 'lodash-es/maxBy' | 17 | import maxBy from 'lodash-es/maxBy' |
10 | import * as CacheChunkStore from 'cache-chunk-store' | 18 | import * as CacheChunkStore from 'cache-chunk-store' |
@@ -262,7 +270,6 @@ class PeerTubePlugin extends Plugin { | |||
262 | 270 | ||
263 | private tryToPlay (done?: Function) { | 271 | private tryToPlay (done?: Function) { |
264 | if (!done) done = function () { /* empty */ } | 272 | if (!done) done = function () { /* empty */ } |
265 | |||
266 | const playPromise = this.player.play() | 273 | const playPromise = this.player.play() |
267 | if (playPromise !== undefined) { | 274 | if (playPromise !== undefined) { |
268 | return playPromise.then(done) | 275 | return playPromise.then(done) |
@@ -348,6 +355,9 @@ class PeerTubePlugin extends Plugin { | |||
348 | // Proxy first play | 355 | // Proxy first play |
349 | const oldPlay = this.player.play.bind(this.player) | 356 | const oldPlay = this.player.play.bind(this.player) |
350 | this.player.play = () => { | 357 | this.player.play = () => { |
358 | // Avoid issue new play policy on mobiles | ||
359 | if (isMobile()) oldPlay() | ||
360 | |||
351 | this.player.addClass('vjs-has-big-play-button-clicked') | 361 | this.player.addClass('vjs-has-big-play-button-clicked') |
352 | this.player.play = oldPlay | 362 | this.player.play = oldPlay |
353 | 363 | ||
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) { | |||
60 | return setLocalStorage('average-bandwidth', value.toString()) | 60 | return setLocalStorage('average-bandwidth', value.toString()) |
61 | } | 61 | } |
62 | 62 | ||
63 | function isMobile () { | ||
64 | return /iPhone|iPad|iPod|Android/i.test(navigator.userAgent) | ||
65 | } | ||
66 | |||
63 | export { | 67 | export { |
64 | toTitleCase, | 68 | toTitleCase, |
65 | getStoredVolume, | 69 | getStoredVolume, |
@@ -68,6 +72,7 @@ export { | |||
68 | getAverageBandwidth, | 72 | getAverageBandwidth, |
69 | saveMuteInStore, | 73 | saveMuteInStore, |
70 | getStoredMute, | 74 | getStoredMute, |
75 | isMobile, | ||
71 | bytes | 76 | bytes |
72 | } | 77 | } |
73 | 78 | ||