Send player state via WebSockets

This commit is contained in:
Rafostar
2020-12-12 19:37:07 +01:00
parent 7a039af798
commit ea7b712b2e
2 changed files with 11 additions and 0 deletions

View File

@@ -334,6 +334,7 @@ class ClapperPlayer extends PlayerBase
_onStateChanged(player, state)
{
this.state = state;
this.emitWs('state-changed', state);
if(state !== GstPlayer.PlayerState.BUFFERING) {
let root = player.widget.get_root();
@@ -362,6 +363,8 @@ class ClapperPlayer extends PlayerBase
_onStreamEnded(player)
{
debug('stream ended');
this.emitWs('stream-ended', this._trackId);
this._trackId++;
if(this._trackId < this._playlist.length)

View File

@@ -181,6 +181,14 @@ class ClapperPlayerBase extends GstPlayer.Player
this.widget.queue_render();
}
emitWs(action, value)
{
if(!this.webserver)
return;
this.webserver.sendMessage({ action, value });
}
_onWsData(server, action, value)
{
debug(`unhandled WebSocket action: ${action}`);