Silly workaround for apple devices

This commit is contained in:
Thomas Lovén 2019-06-28 00:12:12 +02:00
parent 3f133e4c41
commit acccacdff1
3 changed files with 13 additions and 3 deletions

View File

@ -69,6 +69,8 @@ The `media_player` entity also has some extra attributes presenting the current
| `userAgent` | The User Agent of the associated browser. |
| `currentUser` | The user currently logged in on the *device*. |
**NOTE: Because apple is apple; on iOS you need to touch the screen once after loading the frontend before any playback will work.**
## `browser_mod.command` service
Call the `browser_mod.command` service to control your *device* in various ways.

File diff suppressed because one or more lines are too long

View File

@ -28,9 +28,16 @@ class BrowserMod {
document.querySelector("home-assistant").hassChanged(hass, hass);
}
playOnce(ev) {
if(window.browser_mod.playedOnce) return;
window.browser_mod.player.play();
window.browser_mod.playedOnce = true;
}
constructor() {
window.hassConnection.then((conn) => this.connect(conn.conn));
this.player = new Audio();
this.playedOnce = false;
const updater = this.update.bind(this);
this.player.addEventListener("ended", updater);
@ -39,6 +46,7 @@ class BrowserMod {
this.player.addEventListener("volumechange", updater);
document.addEventListener("visibilitychange", updater);
window.addEventListener("location-changed", updater);
window.addEventListener("click", this.playOnce);
provideHass(this);
}