mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 18:41:47 +00:00
use $('video') srcChanged event instead of loadeddata/metadata
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
module.exports = () => {
|
||||
document.addEventListener('apiLoaded', () => {
|
||||
document.querySelector('video').addEventListener('loadeddata', e => {
|
||||
document.querySelector('video').addEventListener('srcChanged', e => {
|
||||
e.target.pause();
|
||||
})
|
||||
}, { once: true, passive: true })
|
||||
|
||||
@ -49,7 +49,7 @@ const observePopupContainer = () => {
|
||||
|
||||
const observeVideo = () => {
|
||||
$('video').addEventListener('ratechange', forcePlaybackRate)
|
||||
$('video').addEventListener('loadeddata', forcePlaybackRate)
|
||||
$('video').addEventListener('srcChanged', forcePlaybackRate)
|
||||
}
|
||||
|
||||
const setupWheelListener = () => {
|
||||
|
||||
@ -35,13 +35,13 @@ function setup() {
|
||||
setOptions("video-toggle", options);
|
||||
})
|
||||
|
||||
$('video').addEventListener('loadedmetadata', videoStarted);
|
||||
$('video').addEventListener('srcChanged', videoStarted);
|
||||
}
|
||||
|
||||
function changeDisplay(showVideo) {
|
||||
if (!showVideo && $('ytmusic-player').getAttribute('playback-mode') !== "ATV_PREFERRED") {
|
||||
if (!showVideo) {
|
||||
$('video').style.top = "0";
|
||||
$('ytmusic-player').style.margin = "auto 21.5px";
|
||||
$('ytmusic-player').style.margin = "auto 0px";
|
||||
$('ytmusic-player').setAttribute('playback-mode', "ATV_PREFERRED");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user