fix: Increase reliability of media auto actions (e.g. play) (#1934)

Refactors media player handling entirely to make the code more
consistent and less boilerplate. Add testing for media player actions.

- Closes #1921
- Closes #1916
This commit is contained in:
Dermot Duffy
2025-03-03 20:59:01 -08:00
committed by GitHub
parent d4650eae8a
commit 3b77b11196
58 changed files with 1972 additions and 1165 deletions
+5 -5
View File
@@ -489,10 +489,10 @@ export class MenuButtonController {
): MenuItem | null {
if (
currentMediaLoadedInfo &&
currentMediaLoadedInfo.player &&
currentMediaLoadedInfo.mediaPlayerController &&
currentMediaLoadedInfo.capabilities?.supportsPause
) {
const paused = currentMediaLoadedInfo.player.isPaused();
const paused = currentMediaLoadedInfo.mediaPlayerController?.isPaused();
return {
icon: paused ? 'mdi:play' : 'mdi:pause',
...config.menu.buttons.play,
@@ -512,10 +512,10 @@ export class MenuButtonController {
): MenuItem | null {
if (
currentMediaLoadedInfo &&
currentMediaLoadedInfo.player &&
currentMediaLoadedInfo.mediaPlayerController &&
currentMediaLoadedInfo?.capabilities?.hasAudio
) {
const muted = currentMediaLoadedInfo.player.isMuted();
const muted = currentMediaLoadedInfo.mediaPlayerController?.isMuted();
return {
icon: muted ? 'mdi:volume-off' : 'mdi:volume-high',
...config.menu.buttons.mute,
@@ -533,7 +533,7 @@ export class MenuButtonController {
config: AdvancedCameraCardConfig,
currentMediaLoadedInfo?: MediaLoadedInfo | null,
): MenuItem | null {
if (currentMediaLoadedInfo && currentMediaLoadedInfo.player) {
if (currentMediaLoadedInfo && currentMediaLoadedInfo.mediaPlayerController) {
return {
icon: 'mdi:monitor-screenshot',
...config.menu.buttons.screenshot,