Add "ended" embed API event
This commit is contained in:
parent
b1f3b635ed
commit
96aae68cc4
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@peertube/embed-api",
|
"name": "@peertube/embed-api",
|
||||||
"private": false,
|
"private": false,
|
||||||
"version": "0.0.1",
|
"version": "0.0.3",
|
||||||
"description": "API to communicate with the PeerTube player embed",
|
"description": "API to communicate with the PeerTube player embed",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
|
|
@ -80,7 +80,7 @@ export class PeerTubeEmbedApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
private setupStateTracking () {
|
private setupStateTracking () {
|
||||||
let currentState: 'playing' | 'paused' | 'unstarted' = 'unstarted'
|
let currentState: 'playing' | 'paused' | 'unstarted' | 'ended' = 'unstarted'
|
||||||
|
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
const position = this.element.currentTime
|
const position = this.element.currentTime
|
||||||
|
@ -106,6 +106,11 @@ export class PeerTubeEmbedApi {
|
||||||
this.channel.notify({ method: 'playbackStatusChange', params: 'paused' })
|
this.channel.notify({ method: 'playbackStatusChange', params: 'paused' })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.element.addEventListener('ended', ev => {
|
||||||
|
currentState = 'ended'
|
||||||
|
this.channel.notify({ method: 'playbackStatusChange', params: 'ended' })
|
||||||
|
})
|
||||||
|
|
||||||
// PeerTube specific capabilities
|
// PeerTube specific capabilities
|
||||||
|
|
||||||
if (this.isWebtorrent()) {
|
if (this.isWebtorrent()) {
|
||||||
|
|
|
@ -123,7 +123,8 @@ Fired every half second to provide the current status of playback. The parameter
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
The `volume` field contains the volume from `0` (silent) to `1` (full volume). The `playbackState` can be `playing` or `paused`. More states may be added later.
|
The `volume` field contains the volume from `0` (silent) to `1` (full volume).
|
||||||
|
The `playbackState` can be `unstarted`, `playing`, `paused` or `ended`. More states may be added later.
|
||||||
|
|
||||||
## Event `playbackStatusChange`
|
## Event `playbackStatusChange`
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue