fix: add null checks for media controller

This commit is contained in:
Slowlife01
2025-04-02 21:36:15 +07:00
parent 8f571d5800
commit bb9711639c

View File

@@ -148,7 +148,9 @@ class ZenMediaController {
} }
showMediaControls() { showMediaControls() {
if (this._currentMediaController?.isBeingUsedInPIPModeOrFullscreen) return this.hideMediaControls(); if (!this._currentMediaController) return;
if (this._currentMediaController.isBeingUsedInPIPModeOrFullscreen) return this.hideMediaControls();
if (!this.mediaControlBar.hasAttribute('hidden')) return; if (!this.mediaControlBar.hasAttribute('hidden')) return;
this.updatePipButton(); this.updatePipButton();
@@ -485,6 +487,8 @@ class ZenMediaController {
} }
updatePipButton() { updatePipButton() {
if (!this._currentBrowser) return;
const isPipEligible = this.pipEligibilityMap.get(this._currentBrowser.browserId); const isPipEligible = this.pipEligibilityMap.get(this._currentBrowser.browserId);
if (isPipEligible) this.mediaControlBar.setAttribute('can-pip', ''); if (isPipEligible) this.mediaControlBar.setAttribute('can-pip', '');
else this.mediaControlBar.removeAttribute('can-pip'); else this.mediaControlBar.removeAttribute('can-pip');