Gamua / Starling-Framework

The Cross Platform Game Engine
http://www.starling-framework.org
Other
2.84k stars 819 forks source link

Texture.fromNetStream does not function as described #908

Closed kevinfoley closed 7 years ago

kevinfoley commented 7 years ago

When Starling 1.7 was released, you recommended creating video textures via this method:

var nc:NetConnection = new NetConnection();
nc.connect(null);

var file:File = File.applicationDirectory.resolvePath("lolcat.m4v");
var ns:NetStream = new NetStream(nc);
ns.play(file.url);

var texture:Texture = Texture.fromNetStream(ns, 1, function():void
{
    addChild(new Image(texture));
});

Using AIR 23 and Starling 2.1, this method works fine on desktops, but does not work on iOS, because the anonymous function is never called, and the Image is never created and added.

Now (according to Starling docs) you recommend this method:

var nc:NetConnection = new NetConnection();
nc.connect(null);

var ns:NetStream = new NetStream(nc);
var texture:Texture = Texture.fromNetStream(ns, 1, function():void
{
    addChild(new Image(texture));
});

var file:File = File.applicationDirectory.resolvePath("bugs-bunny.m4v");
ns.play(file.url);

This method does not appear to work on iOS or desktops. The anonymous function is never called.

Has the syntax changed again?

kevinfoley commented 7 years ago

Silly me, I had a typo!

PrimaryFeather commented 7 years ago

Yes, I updated the documentation because people reported that the order of statements I originally used didn't work everywhere. Thus the change!

In any case, I'm glad to hear you found the problem! :smile: