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
+4 -6
View File
@@ -429,16 +429,14 @@ export class AdvancedCameraCardLiveCarousel extends LitElement {
public updated(changedProperties: PropertyValues): void {
super.updated(changedProperties);
let initialized = false;
if (!this._mediaActionsController.hasRoot() && this._refCarousel.value) {
this._mediaActionsController.initialize(this._refCarousel.value);
initialized = true;
}
const rootChanged = this._refCarousel.value
? this._mediaActionsController.setRoot(this._refCarousel.value)
: false;
// If the view has changed, or if the media actions controller has just been
// initialized, then call the necessary media action.
// See: https://github.com/dermotduffy/advanced-camera-card/issues/1626
if (initialized || changedProperties.has('viewManagerEpoch')) {
if (rootChanged || changedProperties.has('viewManagerEpoch')) {
this._setMediaTarget();
}
}