diff options
author | Chocobozzz <me@florianbigard.com> | 2019-03-13 14:18:58 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-03-18 11:17:59 +0100 |
commit | e2f01c47e08d26a30ad47068d195b3d21d0df8a1 (patch) | |
tree | 21f18ed462d313bfb4ba7a1b5221fdb6b2c35bc1 /client/src/assets/player | |
parent | 15e9d5ca39e0b792f61453fbf3885a0fc446afa7 (diff) | |
download | PeerTube-e2f01c47e08d26a30ad47068d195b3d21d0df8a1.tar.gz PeerTube-e2f01c47e08d26a30ad47068d195b3d21d0df8a1.tar.zst PeerTube-e2f01c47e08d26a30ad47068d195b3d21d0df8a1.zip |
Playlist support in watch page
Diffstat (limited to 'client/src/assets/player')
-rw-r--r-- | client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts | 12 | ||||
-rw-r--r-- | client/src/assets/player/peertube-plugin.ts | 10 |
2 files changed, 19 insertions, 3 deletions
diff --git a/client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts b/client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts index 4dbfda300..bbd3e008d 100644 --- a/client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts +++ b/client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts | |||
@@ -4,6 +4,7 @@ import * as videojs from 'video.js' | |||
4 | import { P2PMediaLoaderPluginOptions, PlayerNetworkInfo, VideoJSComponentInterface } from '../peertube-videojs-typings' | 4 | import { P2PMediaLoaderPluginOptions, PlayerNetworkInfo, VideoJSComponentInterface } from '../peertube-videojs-typings' |
5 | import { Engine, initHlsJsPlayer, initVideoJsContribHlsJsPlayer } from 'p2p-media-loader-hlsjs' | 5 | import { Engine, initHlsJsPlayer, initVideoJsContribHlsJsPlayer } from 'p2p-media-loader-hlsjs' |
6 | import { Events } from 'p2p-media-loader-core' | 6 | import { Events } from 'p2p-media-loader-core' |
7 | import { timeToInt } from '../utils' | ||
7 | 8 | ||
8 | // videojs-hlsjs-plugin needs videojs in window | 9 | // videojs-hlsjs-plugin needs videojs in window |
9 | window['videojs'] = videojs | 10 | window['videojs'] = videojs |
@@ -32,6 +33,7 @@ class P2pMediaLoaderPlugin extends Plugin { | |||
32 | totalDownload: 0, | 33 | totalDownload: 0, |
33 | totalUpload: 0 | 34 | totalUpload: 0 |
34 | } | 35 | } |
36 | private startTime: number | ||
35 | 37 | ||
36 | private networkInfoInterval: any | 38 | private networkInfoInterval: any |
37 | 39 | ||
@@ -54,12 +56,14 @@ class P2pMediaLoaderPlugin extends Plugin { | |||
54 | 56 | ||
55 | initVideoJsContribHlsJsPlayer(player) | 57 | initVideoJsContribHlsJsPlayer(player) |
56 | 58 | ||
59 | this.startTime = timeToInt(options.startTime) | ||
60 | |||
57 | player.src({ | 61 | player.src({ |
58 | type: options.type, | 62 | type: options.type, |
59 | src: options.src | 63 | src: options.src |
60 | }) | 64 | }) |
61 | 65 | ||
62 | player.on('play', () => { | 66 | player.one('play', () => { |
63 | player.addClass('vjs-has-big-play-button-clicked') | 67 | player.addClass('vjs-has-big-play-button-clicked') |
64 | }) | 68 | }) |
65 | 69 | ||
@@ -92,6 +96,12 @@ class P2pMediaLoaderPlugin extends Plugin { | |||
92 | this.statsP2PBytes.numPeers = 1 + this.options.redundancyBaseUrls.length | 96 | this.statsP2PBytes.numPeers = 1 + this.options.redundancyBaseUrls.length |
93 | 97 | ||
94 | this.runStats() | 98 | this.runStats() |
99 | |||
100 | this.hlsjs.on('hlsLevelLoaded', () => { | ||
101 | if (this.startTime) this.player.currentTime(this.startTime) | ||
102 | |||
103 | this.hlsjs.off('hlsLevelLoaded', this) | ||
104 | }) | ||
95 | } | 105 | } |
96 | 106 | ||
97 | private runStats () { | 107 | private runStats () { |
diff --git a/client/src/assets/player/peertube-plugin.ts b/client/src/assets/player/peertube-plugin.ts index 3991e4627..dd9408c8e 100644 --- a/client/src/assets/player/peertube-plugin.ts +++ b/client/src/assets/player/peertube-plugin.ts | |||
@@ -83,9 +83,15 @@ class PeerTubePlugin extends Plugin { | |||
83 | 83 | ||
84 | if (options.stopTime) { | 84 | if (options.stopTime) { |
85 | const stopTime = timeToInt(options.stopTime) | 85 | const stopTime = timeToInt(options.stopTime) |
86 | const self = this | ||
86 | 87 | ||
87 | this.player.on('timeupdate', () => { | 88 | this.player.on('timeupdate', function onTimeUpdate () { |
88 | if (this.player.currentTime() > stopTime) this.player.pause() | 89 | if (self.player.currentTime() > stopTime) { |
90 | self.player.pause() | ||
91 | self.player.trigger('stopped') | ||
92 | |||
93 | self.player.off('timeupdate', onTimeUpdate) | ||
94 | } | ||
89 | }) | 95 | }) |
90 | } | 96 | } |
91 | 97 | ||