mirror of
https://github.com/zen-browser/desktop.git
synced 2025-10-06 18:06:35 +00:00
Merge branch 'dev' of https://github.com/zen-browser/desktop into dev
This commit is contained in:
@@ -75,6 +75,12 @@ class ZenMediaController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.addEventListener('DOMAudioPlaybackStarted', (event) => {
|
||||||
|
this.activateMediaControls(event.target.browsingContext.mediaController, event.target);
|
||||||
|
});
|
||||||
|
|
||||||
|
window.addEventListener('DOMAudioPlaybackStopped', () => this.updateMuteState());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -151,7 +157,7 @@ class ZenMediaController {
|
|||||||
activateMediaControls(mediaController, browser) {
|
activateMediaControls(mediaController, browser) {
|
||||||
this.updateMuteState();
|
this.updateMuteState();
|
||||||
|
|
||||||
if (this._currentBrowser?.browserId === browser.browserId) return;
|
if (!mediaController.isActive || this._currentBrowser?.browserId === browser.browserId) return;
|
||||||
else {
|
else {
|
||||||
this.deinitMediaController(this._currentMediaController);
|
this.deinitMediaController(this._currentMediaController);
|
||||||
this._currentMediaController = mediaController;
|
this._currentMediaController = mediaController;
|
||||||
@@ -222,25 +228,25 @@ class ZenMediaController {
|
|||||||
if (this._currentDuration >= 900_000) return this.mediaControlBar.setAttribute('media-position-hidden', 'true');
|
if (this._currentDuration >= 900_000) return this.mediaControlBar.setAttribute('media-position-hidden', 'true');
|
||||||
else this.mediaControlBar.removeAttribute('media-position-hidden');
|
else this.mediaControlBar.removeAttribute('media-position-hidden');
|
||||||
|
|
||||||
|
if (!this._currentDuration) return;
|
||||||
|
|
||||||
this.mediaCurrentTime.textContent = this.formatSecondsToTime(this._currentPosition);
|
this.mediaCurrentTime.textContent = this.formatSecondsToTime(this._currentPosition);
|
||||||
this.mediaDuration.textContent = this.formatSecondsToTime(this._currentDuration);
|
this.mediaDuration.textContent = this.formatSecondsToTime(this._currentDuration);
|
||||||
this.mediaProgressBar.value = (this._currentPosition / this._currentDuration) * 100;
|
this.mediaProgressBar.value = (this._currentPosition / this._currentDuration) * 100;
|
||||||
|
|
||||||
if (this._currentMediaController?.isPlaying) {
|
this._mediaUpdateInterval = setInterval(() => {
|
||||||
this._mediaUpdateInterval = setInterval(() => {
|
if (this._currentMediaController?.isPlaying) {
|
||||||
if (this._currentMediaController?.isPlaying) {
|
this._currentPosition += 1;
|
||||||
this._currentPosition += 1;
|
if (this._currentPosition > this._currentDuration) {
|
||||||
if (this._currentPosition > this._currentDuration) {
|
this._currentPosition = this._currentDuration;
|
||||||
this._currentPosition = this._currentDuration;
|
|
||||||
}
|
|
||||||
this.mediaCurrentTime.textContent = this.formatSecondsToTime(this._currentPosition);
|
|
||||||
this.mediaProgressBar.value = (this._currentPosition / this._currentDuration) * 100;
|
|
||||||
} else {
|
|
||||||
clearInterval(this._mediaUpdateInterval);
|
|
||||||
this._mediaUpdateInterval = null;
|
|
||||||
}
|
}
|
||||||
}, 1000);
|
this.mediaCurrentTime.textContent = this.formatSecondsToTime(this._currentPosition);
|
||||||
}
|
this.mediaProgressBar.value = (this._currentPosition / this._currentDuration) * 100;
|
||||||
|
} else {
|
||||||
|
clearInterval(this._mediaUpdateInterval);
|
||||||
|
this._mediaUpdateInterval = null;
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,17 +0,0 @@
|
|||||||
diff --git a/toolkit/actors/AudioPlaybackParent.sys.mjs b/toolkit/actors/AudioPlaybackParent.sys.mjs
|
|
||||||
index db682fd90b2bb5330497d2cf2158ff4cac6bbc47..4e6f891275d489418b8ea58a10345a1baa3a554c 100644
|
|
||||||
--- a/toolkit/actors/AudioPlaybackParent.sys.mjs
|
|
||||||
+++ b/toolkit/actors/AudioPlaybackParent.sys.mjs
|
|
||||||
@@ -14,10 +14,12 @@ export class AudioPlaybackParent extends JSWindowActorParent {
|
|
||||||
switch (aMessage.name) {
|
|
||||||
case "AudioPlayback:Start":
|
|
||||||
this._hasAudioPlayback = true;
|
|
||||||
+ browser.ownerGlobal.gZenMediaController.activateMediaControls(this.browsingContext.mediaController, browser);
|
|
||||||
browser.audioPlaybackStarted();
|
|
||||||
break;
|
|
||||||
case "AudioPlayback:Stop":
|
|
||||||
this._hasAudioPlayback = false;
|
|
||||||
+ browser.ownerGlobal.gZenMediaController.updateMuteState();
|
|
||||||
browser.audioPlaybackStopped();
|
|
||||||
break;
|
|
||||||
case "AudioPlayback:ActiveMediaBlockStart":
|
|
Reference in New Issue
Block a user