From 96aae68cc47b7ac9b9400d5b5cf95acdf9fe38da Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 8 Apr 2020 14:39:31 +0200 Subject: Add "ended" embed API event --- client/src/standalone/videos/embed-api.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'client/src/standalone/videos') diff --git a/client/src/standalone/videos/embed-api.ts b/client/src/standalone/videos/embed-api.ts index 61e5d0b9a..c5fbe07fa 100644 --- a/client/src/standalone/videos/embed-api.ts +++ b/client/src/standalone/videos/embed-api.ts @@ -80,7 +80,7 @@ export class PeerTubeEmbedApi { } private setupStateTracking () { - let currentState: 'playing' | 'paused' | 'unstarted' = 'unstarted' + let currentState: 'playing' | 'paused' | 'unstarted' | 'ended' = 'unstarted' setInterval(() => { const position = this.element.currentTime @@ -106,6 +106,11 @@ export class PeerTubeEmbedApi { this.channel.notify({ method: 'playbackStatusChange', params: 'paused' }) }) + this.element.addEventListener('ended', ev => { + currentState = 'ended' + this.channel.notify({ method: 'playbackStatusChange', params: 'ended' }) + }) + // PeerTube specific capabilities if (this.isWebtorrent()) { -- cgit v1.2.3