Skip to content

Commit 7ba1d97

Browse files
committed
Update youtube_meta.html
1 parent e8e8e2c commit 7ba1d97

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

public/youtube_meta.html

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -79,25 +79,27 @@
7979
playerVars: defaultPlayerVars,
8080
host: 'https://www.youtube-nocookie.com',
8181
events: {
82-
'onStateChange': onPlayerStateChange
82+
onStateChange: (event) => {
83+
if (event.data === YT.PlayerState.PLAYING) {
84+
player.setVolume(0)
85+
86+
87+
const videoData = player.getVideoData()
88+
const metadata = {
89+
title: videoData.title,
90+
isLive: videoData.isLive,
91+
isPlayable: videoData.isPlayable, //Age restricted or unplayable
92+
duration: player.getDuration(),
93+
};
94+
95+
console.log("METADATA:" + JSON.stringify(metadata));
96+
}
97+
},
98+
onError: (event) => {
99+
console.log(event)
100+
}
83101
}
84102
});
85-
86-
function onPlayerStateChange(event) {
87-
if (event.data === YT.PlayerState.PLAYING) {
88-
player.setVolume(0)
89-
90-
const videoData = player.getVideoData()
91-
const metadata = {
92-
title: videoData.title,
93-
isLive: videoData.isLive,
94-
isPlayable: videoData.isPlayable, //Age restricted or unplayable
95-
duration: player.getDuration(),
96-
};
97-
98-
console.log("METADATA:" + JSON.stringify(metadata));
99-
}
100-
}
101103
}
102104

103105
/**

0 commit comments

Comments
 (0)