fix: use video.paused for play/pause state detection#87
Merged
Conversation
The play/pause icon was not updating because the JavaScript observer
checked for hardcoded English button text ("Pause") in the title and
aria-label attributes. This fails when YouTube Music is displayed in
a non-English language.
Replace the localized button attribute check with the video element's
`paused` property, which is language-agnostic and more reliable.
Fixes #16
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR makes playback state detection language-agnostic by relying on the <video> element’s paused property instead of localized button text, fixing incorrect play/pause icon state in non-English YouTube Music locales.
Changes:
- In
SingletonPlayerWebView’s observer script, replace checks against the play/pause button’stitle/aria-labelattributes withvideo.pausedto deriveisPlaying. - In
MiniPlayerWebView’s observer script, remove the now-unneededplayPauseBtnlookup and similarly computeisPlayingfrom thevideoelement’spausedproperty.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Views/macOS/SingletonPlayerWebView+ObserverScript.swift | Updates the main player state observer to compute isPlaying from document.querySelector('video') and its paused property, making play/pause detection locale-independent. |
| Views/macOS/MiniPlayerWebView.swift | Aligns the mini player’s observer script with the same video.paused-based isPlaying logic and removes the unused play/pause button reference. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
title === 'Pause') with video element'spausedpropertyRoot Cause
The JavaScript observer scripts checked for hardcoded English text in the play/pause button's
titleandaria-labelattributes. When YouTube Music is displayed in a non-English language (e.g., German, Spanish), these attributes contain localized text, causingisPlayingto always returnfalse.Fix
Use
video.pausedproperty directly instead of checking button text:Test plan
Fixes #16
🤖 Generated with Claude Code