From ea7b712b2e05a31effaea5e4600773b62513af0c Mon Sep 17 00:00:00 2001 From: Rafostar <40623528+Rafostar@users.noreply.github.com> Date: Sat, 12 Dec 2020 19:37:07 +0100 Subject: [PATCH] Send player state via WebSockets --- clapper_src/player.js | 3 +++ clapper_src/playerBase.js | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/clapper_src/player.js b/clapper_src/player.js index be06fddc..fc396493 100644 --- a/clapper_src/player.js +++ b/clapper_src/player.js @@ -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) diff --git a/clapper_src/playerBase.js b/clapper_src/playerBase.js index 17f1ddd8..3e24179a 100644 --- a/clapper_src/playerBase.js +++ b/clapper_src/playerBase.js @@ -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}`);