diff --git a/demo.py b/demo.py index c944e9c..488e97b 100644 --- a/demo.py +++ b/demo.py @@ -74,7 +74,7 @@ class DemoController: # Standing in for a Zidoo plugged into this input, so the # AVR card's now-playing block has something to show here too. "now_playing": {"song": "Big Buck Bunny", "artist": "2008", "image": None, - "position_ms": 241000, "duration_ms": 596000} + "play_state": "play", "position_ms": 241000, "duration_ms": 596000} if self.avr.current_input()["code"] == self.cfg.ZIDOO_INPUT_CODE else None, }, "heos_ok": True, diff --git a/static/app.js b/static/app.js index 1a75dab..d9bc879 100644 --- a/static/app.js +++ b/static/app.js @@ -263,11 +263,11 @@ function paintGrouping() { ui.joined.hidden = inside.length === 0; // Grouped rooms share the host's transport, so one of them playing means // the whole group is -- and the tint goes on the group's card. - const groupPlaying = inside.some((node) => node.classList.contains('playing')); - ui.source.classList.toggle('playing', groupPlaying); - // A film on the Zidoo also moves the AVR up. The Zidoo does not say whether - // it is paused, so a loaded film counts, and it gets no tint. - ui.source.classList.toggle('on-top', groupPlaying || Boolean(avrNowPlaying)); + // A film running on the Zidoo counts as the AVR playing too, grouped rooms or not. + const playing = inside.some((node) => node.classList.contains('playing')) + || avrNowPlaying?.play_state === 'play'; + ui.source.classList.toggle('playing', playing); + ui.source.classList.toggle('on-top', playing); } /* Press and hold to keep moving, accelerating as you hold. */ diff --git a/tests/test_zidoo.py b/tests/test_zidoo.py index fc18e74..119004a 100644 --- a/tests/test_zidoo.py +++ b/tests/test_zidoo.py @@ -73,9 +73,13 @@ class ZidooTest(unittest.TestCase): def test_a_film_carries_its_year_progress_and_poster(self): self.assertEqual(self.zidoo.now_playing(), { "song": "A Private War", "artist": "2018", "image": None, "poster_id": 108, - "position_ms": 1589745, "duration_ms": 6635092, + "play_state": "play", "position_ms": 1589745, "duration_ms": 6635092, }) + def test_a_paused_film_is_still_there_but_paused(self): + FakeZidoo.video["status"] = 0 + self.assertEqual(self.zidoo.now_playing()["play_state"], "pause") + def test_the_poster_is_looked_up_once_per_file(self): self.zidoo.now_playing() self.zidoo.now_playing() diff --git a/zidoo.py b/zidoo.py index 2214321..e132881 100644 --- a/zidoo.py +++ b/zidoo.py @@ -45,7 +45,9 @@ class ZidooClient: instead. "image" is always None: the poster lives on the Zidoo, which the phone cannot load over plain http, so "poster_id" names it instead for app.py to serve. "position_ms" and "duration_ms" come - along whenever the length is known, as a room's do.""" + along whenever the length is known, as a room's do. "play_state" is + "play" while the film runs (the video's "status" is 1), "pause" + otherwise.""" payload = self._get_json("ZidooVideoPlay/getPlayStatus") if not payload or payload.get("status") != 200: return None @@ -56,7 +58,8 @@ class ZidooClient: film = self._film(video.get("path")) year = film.get("year") track = {"song": title, "artist": str(year) if year else None, "image": None, - "poster_id": film.get("id")} + "poster_id": film.get("id"), + "play_state": "play" if video.get("status") == 1 else "pause"} if video.get("duration"): track["position_ms"] = video.get("currentPosition") or 0 track["duration_ms"] = video["duration"]