The open-source Arc replacement for macOS. Spaces, pinned tabs, split view, Little Windows and Arc's shortcuts on Chromium, with your Arc sidebar imported in one go.
A Chromium page played again within 2 s of a pause from the sidebar shows as playing
Victor00396352f0eb
diff --git a/Sources/Cra/Services/BrowserManager.swift b/Sources/Cra/Services/BrowserManager.swiftindex 254302f..25cbb24 100644--- a/Sources/Cra/Services/BrowserManager.swift+++ b/Sources/Cra/Services/BrowserManager.swift@@ -882,6 +882,16 @@ final class BrowserManager: NSObject, @preconcurrency CraBrowserDelegate {delegate?.browserManagerDidUpdate(id)}+ /// The page's sound starting or stopping as it happens, before the 2 s hold `didChangeAudible`+ /// waits out. Sound starting marks the tab's card playing: paused from the card and played+ /// again on the page within the hold, the tab never went quiet, so `didChangeAudible` doesn't+ /// come. Cards come and go only with the held state.+ func browser(_ browser: CraBrowser, didChangeSoundPlaying playing: Bool) {+ guard playing, let id = tabID(of: browser), nowPlaying?.entries.contains(where: { $0.id == id && !$0.playing }) == true else { return }+ nowPlaying?.update(id) { $0.playing = true }+ delegate?.browserManagerDidUpdate(id)+ }+// MARK: Now playing/// Play/pause, previous and next for the sidebar player. The page's own media sessiondiff --git a/Sources/Cra/Services/WebKit/WebKitBrowser.swift b/Sources/Cra/Services/WebKit/WebKitBrowser.swiftindex d4343ad..1f95ea1 100644--- a/Sources/Cra/Services/WebKit/WebKitBrowser.swift+++ b/Sources/Cra/Services/WebKit/WebKitBrowser.swift@@ -246,6 +246,7 @@ final class WebKitBrowser: CraBrowser, WKNavigationDelegate, WKUIDelegate, WKDowprivate func setPlaying(_ now: Bool) {audibleOff?.cancel()audibleOff = nil+ delegate?.browser?(self, didChangeSoundPlaying: now)switch audibleHold.setPlaying(now) {case .announce:delegate?.browser?(self, didChangeAudible: true)diff --git a/Sources/CraCEF/CraCEF.mm b/Sources/CraCEF/CraCEF.mmindex 4041f59..9e43d4f 100644--- a/Sources/CraCEF/CraCEF.mm+++ b/Sources/CraCEF/CraCEF.mm@@ -2371,6 +2371,8 @@ class CraDevToolsObserver : public CefDevToolsMessageObserver {// gap between two tracks doesn't blink the speaker.- (void)audibleChanged:(BOOL)audible {NSUInteger change = ++_audibleChanges;+ if ([self.delegate respondsToSelector:@selector(browser:didChangeSoundPlaying:)])+ [self.delegate browser:self didChangeSoundPlaying:audible];if (audible) { [self updateAudible:YES]; return; }__weak CraBrowser* weakSelf = self;dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{diff --git a/Sources/CraCEF/include/CraCEF.h b/Sources/CraCEF/include/CraCEF.hindex ad16d19..3eb176b 100644--- a/Sources/CraCEF/include/CraCEF.h+++ b/Sources/CraCEF/include/CraCEF.h@@ -110,6 +110,9 @@ typedef NS_ENUM(NSInteger, CraLinkWindow) {- (void)browser:(CraBrowser *)browser didChangeMediaCapture:(BOOL)capturing;/// The page started or stopped playing sound (see `isAudible`).- (void)browser:(CraBrowser *)browser didChangeAudible:(BOOL)audible;+/// The page's sound started or stopped as it happened, before the 2 s that `isAudible` and+/// `browser:didChangeAudible:` hold a quiet page audible.+- (void)browser:(CraBrowser *)browser didChangeSoundPlaying:(BOOL)playing;/// `hasCommittedLoad` changed: the main frame committed, or a new navigation started.- (void)browser:(CraBrowser *)browser didChangeCommittedLoad:(BOOL)committed;/// The page's main-frame load failed with a net error (ERR_ABORTED, a navigation cut off,diff --git a/Tests/BrowserManagerLifecycleTests.swift b/Tests/BrowserManagerLifecycleTests.swiftindex 57656ea..345c631 100644--- a/Tests/BrowserManagerLifecycleTests.swift+++ b/Tests/BrowserManagerLifecycleTests.swift@@ -112,6 +112,7 @@ enum BrowserManagerLifecycleTests {extensionTabActivationCase()await beforeUnloadCase()nowPlayingCase()+ await nowPlayingResumeWithinHoldCase()await nowPlayingPictureInPictureCase()nowPlayingSkipsPictureInPictureCase()await leaveVideoTabPictureInPictureCase()@@ -826,6 +827,38 @@ enum BrowserManagerLifecycleTests {manager.closeAll()}+ /// Paused from the sidebar's card, then played again on the page within the 2 s the engine+ /// holds a quiet tab audible: the tab never went quiet, so only its sound starting tells the+ /// card. Before, the card stayed on paused while the page played (Chromium and WebKit, 7 Nov 2026).+ @MainActor+ private static func nowPlayingResumeWithinHoldCase() async {+ let store = SidebarStore()+ let manager = BrowserManager(store: store, favicons: FaviconCache(), container: NSView())+ let np = NowPlaying()+ manager.nowPlaying = np+ let a = store.createTab(url: "https://music.example.test/").id, b = store.createTab(url: "https://example.test/other").id+ let ra = manager.ensureRuntime(for: a)!, rb = manager.ensureRuntime(for: b)!+ manager.show(b, focus: false)+ ra.browser.isAudible = true+ manager.browser(ra.browser, didChangeSoundPlaying: true)+ manager.browser(ra.browser, didChangeAudible: true)+ ra.browser.reply(to: "Cra.mediaSession", with: #"{"actions":["play","pause"],"pictureInPicture":false}"#)+ await drainMainQueue()+ ra.browser.replies.removeAll()+ manager.performNowPlaying(a, .togglePlayback)+ ra.browser.reply(to: "cra:Runtime.evaluate", with: #"{"result":{"type":"string","value":"playing"}}"#)+ await drainMainQueue()+ ra.browser.reply(to: "Cra.mediaSession", with: #"{"handled":true,"pictureInPicture":false}"#)+ await drainMainQueue()+ expect(np.entries.first?.playing == false, "paused from the card, the card shows paused")+ manager.browser(ra.browser, didChangeSoundPlaying: false)+ manager.browser(ra.browser, didChangeSoundPlaying: true)+ expect(np.entries.first?.playing == true, "the page playing again within the hold shows on the card")+ manager.browser(rb.browser, didChangeSoundPlaying: true)+ expect(np.entries.map(\.id) == [a], "sound alone doesn't make a card: the held audible state does")+ manager.closeAll()+ }+// promise: #33/// The sidebar player (#33) has no card for a tab whose video is in Picture in Picture; the/// card comes back when the video leaves it.