18 December 2008

Progressive download in AS3 won't work together with the YouTube Chromeless Player

or, in other words: progressive download in AVM2 doesn't work after usign progressive download in an AVM1 movie loaded in an AVM2 SWF.

The goal: create a video player that can play YouTube clips alongside with videos from any other source (progressive download by direct URL).

I used the ActionScript 3.0 Wrapper for Chromeless Player for YouTube playback and had several options to choose from for progressive download: FLVPlayback, VideoPlayer (both come in the FLVPlayback.swc (source too) with Flash CS3/CS4) and a custom built video player. All three players worked fine in debugging (mode in which YouTube will refuse to work) but when I started using the YouTubeLoader all three failed. Apparently there was a problem with the NetConnection use by the NetStream inside the players.

Finally after a lot of head-scratching I localized the problem to the constructor of the NetStream which obviously should have worked (as it used a null-connected NetConnection).

I tried the most simple instantiation of a NetStream and the same problem persisted. Finally I had to give up progressive download/playback functionality in favor of just YouTube playback.

The runtime error:
ArgumentError: Error #2126: NetConnection object must be connected.
at flash.net::NetStream/construct()
at flash.net::NetStream()
is thrown by this:
var netConnection:NetConnection = new NetConnection();
netConnection.connect(null);
var netStream:NetStream = new NetStream( netConnection );

If someone can see where is my mistake, please help, because I can't see it. It's the way I've always done progressive download and it's the way AS documentation tells us it's done.

Note: The issue appears only after playing back YouTube videos with the chromeless player.

Bug Reported on Adobe JIRA

Finally, I reported the issue on Adobe's Bug Tracker:
[#FP-1215] NetStream will not connect to NetConnection after using progressive download in a loaded AVM1 SWF, in hope that someone at Adobe may know what's the problem or fix the bug (because that's what it seems to be to me).

Although I know that the discoverability of this problem is minimal, but please vote for this issue if it's not a big of a favor to ask and you see the point in it. :)

0 comments: