Ivan Korneev
Ivan Korneev

Reputation: 43

YouTube AS3 API (onReady doesn't work more ?)

YouTube AS3 API . This simple code was writed long time ago . and all was ok . But some days ago some problems. Early (up to 18th this month) all working OK. Flash player using AS3 API.

    public function Main()
          {
                 super();
                 Security.allowInsecureDomain("*");
                 Security.allowDomain("*");
                 stage.align = StageAlign.TOP_LEFT;
                 stage.scaleMode = StageScaleMode.SHOW_ALL;
                 this._loader = new Loader();
                 this._loader.contentLoaderInfo.addEventListener(Event.INIT,this._onLoaderInit);
                 this._loader.addEventListener(IOErrorEvent.IO_ERROR,this.errorHandlerIOErrorEvent);
                 this._loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,this.errorHandlerIOErrorEvent);
                 this._loader.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR,this.onUncaughtError);
                 this.loadTime = new Date();
                 this._loader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3");
    }

    private function _onLoaderInit(param1:Event) : void
          {
             this.player = this._loader.content;
             this.player.addEventListener("onReady",this.onPlayerReady);
             this.player.x = 0;
             this.player.y = 0;
             addChild(DisplayObject(this.player));
             this._loader.contentLoaderInfo.removeEventListener(Event.INIT,this._onLoaderInit);
             this._loader = null;
    }

function onPlayerReady(param1:Event) : void // start from 18th this month , onReady dont fired
{

}

is somebody know this issue , or how fix it ? Thx .

Upvotes: 1

Views: 845

Answers (5)

Dopor
Dopor

Reputation: 21

I've encountered the same issue. I use this API to display a Youtube video (chromeless player) within a flash-based game. So, sadly I'm unable to switch to the HTML5 player, as it doesn't work inside Flash. As I'm stuck with the Flash-based Youtube API, I've tried to solve this issue like OP.

After some investigations, I've found that: - The host address of the API have been moved around February 18th. (now on the googleapis.com domain instead of youtube.com) - After this domain move, the API is unable to load correctly from Youtube. As described in the doc, when you load the API, it should trigger a "onReady" event. Currently, that never happens. - Calling any method described in the doc (loadVideo(), stopVideo(), etc.) on the player will now result in a "method X() doesn't exist" error. So it's not just the "onReady" event no firing, but that the API is failing to load itself - A further proof that something is wrong with the Flash Player API on Youtube side, is that opening the chromless player URL in a browser no longer display a "Youtube" logo, as it used to be. - My suggestion would be that they forgot to rewrote some inner URL when they moved the API from a domain to another, and now it can no longer load all its dependencies or something like that.

Unfortunately, this doesn't solve the problem, just refine where it is.

I think the only way would be to get in touch with Youtube so they "fix" whatever is wrong with their current API. Unless they disabled it voluntarily (which would be sad, as HTML5 can't cover all the uses the AS3 player did).

Upvotes: 2

Hattori Hanzō
Hattori Hanzō

Reputation: 2483

try this open source solution https://github.com/myflashlab/AS3-youtube-parser-video-link

Upvotes: 1

Ivan Korneev
Ivan Korneev

Reputation: 43

Thx to @All for responses. I found some intresting thing .

apiplayer.api have function in class DirectAccessAPI

protected function forwardAPICall(param1:String, param2:Array)
        {
            var _loc_3:* = new APICallEvent(this.API_CALL, param1, param2);
            this.loader.contentLoaderInfo.sharedEvents.dispatchEvent(_loc_3);
            return _loc_3.returnValue;
        }// end function

but API_CALL constant is member of APICallEvent , i just fix it like this

var _loc_3:* = new APICallEvent(APICallEvent.API_CALL, param1, param2);

and all ok , but now i need load apiplayer from local storage , not from youtube.

Upvotes: 2

VC.One
VC.One

Reputation: 15906

  • Try https for Youtube path. Eg: .load(new URLRequest("https://www.youtube.com/api...etc

  • Instead of http://www.youtube.com/apiplayer?version=3
    try: https://youtube.googleapis.com/apiplayer?version=3

Upvotes: 1

user6431119
user6431119

Reputation:

@Ivan Korneev

This is the answer. The YouTube API for AS3 (Flash) has been depreciated. I know this because it just broke in our application a few days ago, luckily we moved over the HTML5. I suggest you do the same. You can learn more here https://developers.google.com/youtube/iframe_api_reference

Upvotes: 2

Related Questions