File tree Expand file tree Collapse file tree 1 file changed +19
-17
lines changed
Expand file tree Collapse file tree 1 file changed +19
-17
lines changed Original file line number Diff line number Diff line change 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 /**
You can’t perform that action at this time.
0 commit comments