diff options
Diffstat (limited to 'client/src/assets/player/peertube-plugin.ts')
-rw-r--r-- | client/src/assets/player/peertube-plugin.ts | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/client/src/assets/player/peertube-plugin.ts b/client/src/assets/player/peertube-plugin.ts index 92ac57cf5..3991e4627 100644 --- a/client/src/assets/player/peertube-plugin.ts +++ b/client/src/assets/player/peertube-plugin.ts | |||
@@ -22,7 +22,6 @@ import { | |||
22 | 22 | ||
23 | const Plugin: VideoJSComponentInterface = videojs.getPlugin('plugin') | 23 | const Plugin: VideoJSComponentInterface = videojs.getPlugin('plugin') |
24 | class PeerTubePlugin extends Plugin { | 24 | class PeerTubePlugin extends Plugin { |
25 | private readonly startTime: number = 0 | ||
26 | private readonly videoViewUrl: string | 25 | private readonly videoViewUrl: string |
27 | private readonly videoDuration: number | 26 | private readonly videoDuration: number |
28 | private readonly CONSTANTS = { | 27 | private readonly CONSTANTS = { |
@@ -35,13 +34,11 @@ class PeerTubePlugin extends Plugin { | |||
35 | 34 | ||
36 | private videoViewInterval: any | 35 | private videoViewInterval: any |
37 | private userWatchingVideoInterval: any | 36 | private userWatchingVideoInterval: any |
38 | private qualityObservationTimer: any | ||
39 | private lastResolutionChange: ResolutionUpdateData | 37 | private lastResolutionChange: ResolutionUpdateData |
40 | 38 | ||
41 | constructor (player: videojs.Player, options: PeerTubePluginOptions) { | 39 | constructor (player: videojs.Player, options: PeerTubePluginOptions) { |
42 | super(player, options) | 40 | super(player, options) |
43 | 41 | ||
44 | this.startTime = timeToInt(options.startTime) | ||
45 | this.videoViewUrl = options.videoViewUrl | 42 | this.videoViewUrl = options.videoViewUrl |
46 | this.videoDuration = options.videoDuration | 43 | this.videoDuration = options.videoDuration |
47 | this.videoCaptions = options.videoCaptions | 44 | this.videoCaptions = options.videoCaptions |
@@ -84,6 +81,14 @@ class PeerTubePlugin extends Plugin { | |||
84 | saveMuteInStore(this.player.muted()) | 81 | saveMuteInStore(this.player.muted()) |
85 | }) | 82 | }) |
86 | 83 | ||
84 | if (options.stopTime) { | ||
85 | const stopTime = timeToInt(options.stopTime) | ||
86 | |||
87 | this.player.on('timeupdate', () => { | ||
88 | if (this.player.currentTime() > stopTime) this.player.pause() | ||
89 | }) | ||
90 | } | ||
91 | |||
87 | this.player.textTracks().on('change', () => { | 92 | this.player.textTracks().on('change', () => { |
88 | const showing = this.player.textTracks().tracks_.find((t: { kind: string, mode: string }) => { | 93 | const showing = this.player.textTracks().tracks_.find((t: { kind: string, mode: string }) => { |
89 | return t.kind === 'captions' && t.mode === 'showing' | 94 | return t.kind === 'captions' && t.mode === 'showing' |
@@ -109,10 +114,7 @@ class PeerTubePlugin extends Plugin { | |||
109 | } | 114 | } |
110 | 115 | ||
111 | dispose () { | 116 | dispose () { |
112 | clearTimeout(this.qualityObservationTimer) | 117 | if (this.videoViewInterval) clearInterval(this.videoViewInterval) |
113 | |||
114 | clearInterval(this.videoViewInterval) | ||
115 | |||
116 | if (this.userWatchingVideoInterval) clearInterval(this.userWatchingVideoInterval) | 118 | if (this.userWatchingVideoInterval) clearInterval(this.userWatchingVideoInterval) |
117 | } | 119 | } |
118 | 120 | ||