As we all know, the Youtube API for ActionScript has been discontinued. So, I looked for alternatives to run the Youtube videos in my Adobe AIR application.
I tested those codes. Below is what happened to each one.
1° Code:
var hl:HTMLLoader = new HTMLLoader();
hl.width = 500;
hl.height = 300;
hl.addEventListener(Event.COMPLETE, complete); //event is dispatched, but with js errors
hl.load(new URLRequest("http://www.youtube.com/embed/XXXXX"));
Result: The error 'Object.freeze is not a function' occours
2° Code:
var webView:StageWebView = new StageWebView();
webView.viewPort = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
webView.stage = stage;
webView.addEventListener(Event.COMPLETE, complete); //event is dispatched, but with js errors
webView.loadURL("http://www.youtube.com/embed/XXXXX");
Result: The same error 'Object.freeze is not a function' occours.
3° Code:
// changed 'useNative' param to true for StageWebView
var webView:StageWebView = new StageWebView(true);
// the same code of 2° Code
Result: No errors, but the page does not load fully and the video don't play.
4° Code:
// I've changed loadURL to loadString, for both methods...
var stringPage:String = '<html><head></head><body><iframe width="640" height="360" src="http://youtube.com/embed/XXXXXX" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></body></html>';
webView.loadString(stringPage);
// or
hl.loadString(stringPage);
Result: A black rectangle appears, but the video don't load.
5° Code:
// I've tried use the AS3 API URL:
hl.load(new URLRequest("http://www.youtube.com/v/XXXXXX"));
// or
webView.loadURL("http://www.youtube.com/v/XXXXXX");
Result: A message "Flash-embedded videos are no longer supported" appears and Video don't play.
"Stranger Things":
// the Youtube Page Video works!
webView.loadURL("http://www.youtube.com/watch?v=XXXXXX");
// or
hl.load(new URLResquest("http://www.youtube.com/watch?v=XXXXXX"));
The question is: someone knows how to load a Youtube Video with ActionScript 3.0 in this year 2019?
from Load YouTube video with AS3 Adobe AIR
No comments:
Post a Comment