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 loadeddata/metadata video events rarely not firing (+other small fixes) #477

Merged

Conversation

Araxeus
Copy link
Collaborator

@Araxeus Araxeus commented Nov 9, 2021

Fix #473
I've been testing stuff with @FiestaLake over on discord

it seems some users had a bug with the video events: dataloaded or metadataloaded not firing, and also the video.src property wasn't changing,

this PR makes use of the api's videodatachange event (specifically when its internal name is dataloaded) and populates it on the video element so that it can be accessed easily with the new srcChanged video event
(This allows plugins to know when a new video started in a bug free way)

this PR also change the way songInfo send callbacks (page-title update was messy, would send alot of updates for no reason)
now songInfo is sent everytime playback is started and isPaused + elapsedSeconds are updated when playback is paused\unpaused\seeked

Other small included fixes

  • fix a grey thumbnail issue that occasionally occurred in video-toggle plugin because the thumbnail.src was overridden by the website after it was set programmatically (fixed using a mutation observer)

  • fix weird aspect ratio of thumbnail in song-info and video-toggle using url.split("?")[0] to filter query from thumbnail-url that resulted in cropped thumbnails
    (only when a video is present and the url is i.ytimg.com/vi/videoid/quality.jpg?query and not when the player is in song mode and the url is lh3.googleusercontent.com/verylongid=w544-h544-l90-rj)

  • speed up sponsorblock plugin by using ipcMain.on("video-src-changed") instead of registerCallback() (which is slower)

  • 185ebbf fix playlist downloading that was broken in last update (fix Error: No playlist ID found #497)
    it also changes the default way of getting the playlistId to 'Currently-Shown-Playlist OR Currently-Playing-Playlist' (it was the other way around before which made less sense IMO)

  • fix disable-autoplay plugin for some people with slower internet, below is a short explanation of how it works:

    apiEvent.detail.addEventListener('videodatachange', name => {
    if (name === 'dataloaded') {
    apiEvent.detail.pauseVideo();
    document.querySelector('video').ontimeupdate = e => {
    e.target.pause();
    }
    } else {
    document.querySelector('video').ontimeupdate = null;
    }
    })

    on video start 2 events are always sent, dataloaded first and then dataupdated. the video tries to start between these 2 events and thats why it pauses on time update between them. (this is method is independent of internet speed)
    also its important to note that dataloaded is only happen on video load while dataupdated might happen at other times

@Araxeus Araxeus changed the title Fix loadeddata/metdata events rarely not firing Fix loadeddata/metadata events rarely not firing Nov 9, 2021
@Araxeus Araxeus changed the title Fix loadeddata/metadata events rarely not firing Fix loadeddata/metadata video events rarely not firing Nov 9, 2021
@Araxeus Araxeus force-pushed the fix-loadeddata/metdata-events-rarely-not-firing branch from b279b99 to 6dbed73 Compare November 9, 2021 16:52
@saltyming
Copy link

saltyming commented Nov 9, 2021

(We spent 9 hours. And he couldn't play Forza Horizon 5 for this period. Just saying :p)
I hope this pr gets merged soon so I can enjoy this fix in a binary package.

@Araxeus Araxeus changed the title Fix loadeddata/metadata video events rarely not firing Fix loadeddata/metadata video events rarely not firing (+other small fixes) Nov 10, 2021
@Araxeus Araxeus force-pushed the fix-loadeddata/metdata-events-rarely-not-firing branch from 035bd56 to 6726e26 Compare November 14, 2021 21:49
@Araxeus Araxeus force-pushed the fix-loadeddata/metdata-events-rarely-not-firing branch from 68f556d to 8c5ac17 Compare November 23, 2021 16:53
@Araxeus
Copy link
Collaborator Author

Araxeus commented Nov 29, 2021

@th-ch This PR should probably be merged before the others to allow fixing merge conflicts if needed

Also would be nice if you could add me on Discord Araxeus#0819 or give some other way to contact you 🙂

Copy link
Owner

@th-ch th-ch left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for the improvements! ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error: No playlist ID found The app doesn't update music info correctly when music is not skipped.
3 participants