diff --git a/custom_components/webrtc/www/webrtc-camera.js b/custom_components/webrtc/www/webrtc-camera.js index c751ec9..2cf8e6b 100644 --- a/custom_components/webrtc/www/webrtc-camera.js +++ b/custom_components/webrtc/www/webrtc-camera.js @@ -260,10 +260,34 @@ class WebRTCCamera extends VideoRTC { const mode = this.querySelector('.mode'); mode.addEventListener('click', () => this.nextStream(true)); + const player = this.querySelector('.player'); + + // Tap action + player.addEventListener('click', e => { + if (this.config.tap_action && this.config.tap_action.action) { + this.handleAction("tap", this.config); + e.preventDefault(); + } + }); + if (this.config.muted) this.video.muted = true; if (this.config.poster_remote) this.video.poster = this.config.poster; } + handleAction(action, config) { + const event = new Event("hass-action", { + bubbles: true, + composed: true, + }); + + event.detail = { + config: config, + action: action + } + + this.dispatchEvent(event); + } + renderDigitalPTZ() { if (this.config.digital_ptz === false) return; new DigitalPTZ(