P.O.W.
P.O.W.

Reputation: 2215

Videotextures doesn't play mp4 in starling 1.7 / Air 18 on iOS

I've tried this code to play a video on my iphone with starling 1.7:

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

var file:File = File.applicationDirectory.resolvePath("video.mp4");

var ns:NetStream = new NetStream(nc);
ns.play(file.url);

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

(code directly from starling blog)

It works on simulator, works with android ...but not on iPhone/iPad.

Webcam works both on simulator and iPhone:

        var camera:Camera = Camera.getCamera();
        var texture2:Texture = Texture.fromCamera(camera, 1, function():void{
            addChild(new Image(texture2));
        });

So this should be an encoding issue for the video, but how should I encode a video to use on ios to play a video as videotexture?

The same video.mp4 works if I play it without stage3D.

thx

Upvotes: 1

Views: 746

Answers (1)

Social0
Social0

Reputation: 21

To fix this issue on iOS, you need to call play() after Texture.fromNetStream()

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

var file:File = File.applicationDirectory.resolvePath("video.mp4");

var ns:NetStream = new NetStream(nc);

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

ns.play(file.url);

Upvotes: 2

Related Questions