File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3232
3333 $scope . play = function ( youtube_id ) {
3434 youtubePlayerApi . loadPlayer ( ) . then ( function ( player ) {
35- if ( player . getVideoData ( ) . video_id === youtube_id ) return ;
35+ try {
36+ if ( player . getVideoData ( ) . video_id === youtube_id ) return ;
37+ }
38+ catch ( err ) {
39+ // There has been an error trying to get video data from the player API (provided by Youtube)
40+ // Pass this error silently
41+ }
42+ // Enforce now which video must be played
3643 player . cueVideoById ( youtube_id ) ;
3744 } ) ;
3845 } ;
Original file line number Diff line number Diff line change 4141 $scope . playerReady = false ;
4242 youtubePlayerApi . loadPlayer ( ) . then ( function ( p ) {
4343 player = p ;
44+ player . cueVideoById ( youtubePlayerApi . videoId ) ;
4445 $scope . playerReady = true ;
4546 } ) ;
4647
Original file line number Diff line number Diff line change 7878 $scope . section = 'video' ;
7979
8080 youtubePlayerApi . loadPlayer ( ) . then ( function ( player ) {
81- if ( player . getVideoData ( ) &&
82- player . getVideoData ( ) . video_id === youtube_id ) return ;
81+ try {
82+ if ( player . getVideoData ( ) &&
83+ player . getVideoData ( ) . video_id === youtube_id )
84+ return ;
85+ }
86+ catch ( err ) {
87+ // There has been an error trying to get video data from the player API (provided by Youtube)
88+ // Pass this error silently
89+ }
90+ // Enforce now which video must be played
8391 player . cueVideoById ( youtube_id ) ;
8492 } ) ;
8593 } else {
315323 var lastState = - 1 ;
316324
317325 function onPlayerStateChange ( event ) {
318- var video_id = event . target . getVideoData ( ) . video_id ;
326+ try {
327+ var video_id = event . target . getVideoData ( ) . video_id ;
328+ }
329+ catch ( err ) {
330+ // There has been an error trying to get video data from the player API (provided by Youtube)
331+ // Pass this error silently
332+ }
319333
320334 if ( event . data == YT . PlayerState . ENDED ) {
321335 if ( ! ( lastState === YT . PlayerState . PAUSED || // workaround, YT in html5 mode will fire
You can’t perform that action at this time.
0 commit comments