Wednesday 15 June 2011

air - Embedding multiple videos causes error in youtube api -


I have created several HTMLLoader to embed YouTube videos into an AirAp (a per-loader) I am using. And when I add more than two, on the other side there is an error in the API for all the players. The player works well, but the events are never called, and players. The reason the video is undefined.

  TypeError: The result of expression 'B' [undefined] is not an object. At http://s.ytimg.com/yts/jsbin/www-embed-player-vflJ4hakx.js: 206 at http://s.ytimg.com/yts/jsbin/www-embed-player-vflJ4hakx.js 204.js at http://sytimg.com/yts/jsbin/www-embed-player-vflJ4hakx.js: 205 at: http://im.itimg.com/yts/jsbin/www-embed-player-vflJ4hakx : 199   

My embed code:

  Function setup youtube player (divName, videoID) {_videoID = videoID; _divName = divName; Var tag = document.createElement ('script'); Tag src = "https://www.youtube.com/iframe_api"; On firstScriptTag = document.getElementsByTagName (such as script ') [0]; FirstScriptTag.parentNode.insertBefore (tag, firstScriptTag); } Var _videoID; Var _divName; Var player; Function onTubeIframeAPIReady () {player = new YT.Player (_divName, {height: '100%', width: '100%', wmode: 'opaque', autohide: '1', normal branding: '1', frameborder : '0', Shinfu: '0', Video: _VideoID, PlayerWars: {'Walm': 'opaque', 'Reliance': 0, 'AutoHead': 1, 'Modest branding': 1, 'frameborder': 0, 'ShowInfo': 0,}, Event: {'Onestate Change': Onplayerstate Change}}}}    

It seems that you are repeatedly calling the following lines:

  var tag = document.createElement ('script'); tag src = "https://www.youtube.com/iframe_api"; on firstScriptTag = document.getElementsByTagName (such as script ') [0]; firstScriptTag ParentNode.insertBefore (tag, firstScriptTag);   

They need to be executed only once, YT.Player to draw definitions and related APIs. You make sure that only once executed, then what things work as expected?

No comments:

Post a Comment