Youtube, AIR and StageWebView

If you want to insert a Youtube video in your Adobe AIR app, you’re lucky. The most important thing is to know the player URL:

This URL works in almost all devices and browsers, if your browser don’t support flash player an HTML5 player will be used. In order to use the magic URL, we create our own browser with the following code:

var videoView : StageWebView = new StageWebView();
var youtubeId : String = "6yCIDkFI7ew";

videoView.stage = this.stage;

// are you using Starling?
// videoView.stage = Starling.current.nativeStage;
videoView.viewPort = new Rectangle(0,  0,
                                            + youtube_id);

In mobile devices this address will use the native player with many options like volume, fullscreen and more. Pretty good solution.