Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Framasoft
PeerTube
PeerTube
Commits
6ccdf9d5
Verified
Commit
6ccdf9d5
authored
Apr 08, 2020
by
Chocobozzz
Browse files
Add duration in embed api playbackStatusUpdate
parent
afd1a6ed
Pipeline
#234997
passed with stages
in 74 minutes and 15 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
client/src/standalone/player/package.json
View file @
6ccdf9d5
{
"name"
:
"@peertube/embed-api"
,
"private"
:
false
,
"version"
:
"0.0.
3
"
,
"version"
:
"0.0.
4
"
,
"description"
:
"API to communicate with the PeerTube player embed"
,
"scripts"
:
{
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
...
...
client/src/standalone/videos/embed-api.ts
View file @
6ccdf9d5
...
...
@@ -85,12 +85,14 @@ export class PeerTubeEmbedApi {
setInterval
(()
=>
{
const
position
=
this
.
element
.
currentTime
const
volume
=
this
.
element
.
volume
const
duration
=
this
.
element
.
duration
this
.
channel
.
notify
({
method
:
'
playbackStatusUpdate
'
,
params
:
{
position
,
volume
,
duration
:
this
.
embed
.
player
.
duration
(),
playbackState
:
currentState
}
})
...
...
client/src/standalone/videos/test-embed.ts
View file @
6ccdf9d5
...
...
@@ -8,7 +8,7 @@ window.addEventListener('load', async () => {
const
videoId
=
lastPart
.
indexOf
(
'
?
'
)
===
-
1
?
lastPart
:
lastPart
.
split
(
'
?
'
)[
0
]
const
iframe
=
document
.
createElement
(
'
iframe
'
)
iframe
.
src
=
`/videos/embed/
${
videoId
}
?
autoplay=1&controls=0&
api=1`
iframe
.
src
=
`/videos/embed/
${
videoId
}
?api=1`
const
mainElement
=
document
.
querySelector
(
'
#host
'
)
mainElement
.
appendChild
(
iframe
)
...
...
support/doc/api/embeds.md
View file @
6ccdf9d5
...
...
@@ -113,12 +113,14 @@ You can subscribe to events by using `addEventListener()`. See above for details
## Event `playbackStatusUpdate`
Fired every half second to provide the current status of playback. The parameter of the callback will resemble:
Fired every half second to provide the current status of playback.
The parameter of the callback will resemble:
```
json
{
"position"
:
22.3
,
"volume"
:
0.9
,
"duration"
:
"171.37499"
,
"playbackState"
:
"playing"
}
```
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment