Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Ambient Mode not working for videos after restart #2255

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/plugins/ambient-mode/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,18 @@ export default createPlugin({
const songImage = document.querySelector<HTMLImageElement>('#song-image');
const songVideo = document.querySelector<HTMLDivElement>('#song-video');
const image = songImage?.querySelector<HTMLImageElement>('yt-img-shadow > img');
const video = songVideo?.querySelector<HTMLVideoElement>('.html5-video-container > video');
const video = await waitForVideo();

async function waitForVideo() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see

waitForElem(selector: string) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,

I tried to comply with your request, however I am not able to edit the code to your wishes, due to my lack of knowledge and experience. My current version involved a lot of experimenting as well as asking ChatGPT for help.

So if anyone else would be able to take a look and edit it accordingly, that would be great. If not, please close this request and I will continue to build the app myself with my suboptimal fix.

let video = null;

while (video == null) {
video = songVideo?.querySelector<HTMLVideoElement>('.html5-video-container > video');
await new Promise(resolve => setTimeout(resolve, 100));
}
return video;
}

const videoWrapper = document.querySelector('#song-video > .player-wrapper');

const injectBlurImage = () => {
Expand Down
Loading