iprodanovbg / homeassistant-desktop

🎛 Desktop application (Windows / macOS / Linux) for Home Assistant built with Electron
Apache License 2.0
432 stars 45 forks source link

Enable Media Autoplay #5

Open kpd328 opened 1 year ago

kpd328 commented 1 year ago

One of the use cases I imagine for a desktop app is to use it as a media player entity with the browser mod hacs integration. And while the browser mod side seems to be working fine, the app doesn't playback media when played, nor does it ask for permissions like a conventional browser does, remaining completely mute.

I believe it has to do with a media autoplay permission with electron and chromium.

iprodanovbg commented 1 year ago

Hello,

HACS itself is an add-on to Home Assistant and there are so many integrations can you be more specific what integration is not working

philpownall commented 1 year ago

Browser-mod is the integration. In homeassistant-desktop, if you browse to Media and select a local media file, the destination appears in the bottom right corner. For the homeassistant-desktop instance, the destination is BROWSER (all caps). And if you select a local media file, it plays. However, when defining an Automation, the destination BROWSER does not appear, so sound cannot be played by the Automation. The browser-mod integration https://github.com/thomasloven/hass-browser_mod allows the user to register chrome browser instances as media destinations - "registration" in this sense means adding a destination using an id to the Home Assistant server, which then enables the id as a destination media player for use in Automations. Does Chromium-Electron permit the use of audio?

philpownall commented 1 year ago

I tried quitting and restarting the homeassistant-desktop instance after using Browser-mod to register the instance as a media destination, and when the homeassistant-desktop restarts, the instance is now listed in the destinations for Media. I changed an Automation to use this destination, and the sound file now plays on the target machine. I know that for Chrome to play the audio, I had to use the chrome://flags/#unsafely-treat-insecure-origin-as-secure flag to enable media over my local IP network, but this was not required in Electron-Chromium used by homeassistant-desktop.