1

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

MGY
  • 7,245
  • 5
  • 41
  • 74
P.O.W.
  • 1,895
  • 1
  • 16
  • 14

1 Answers1

2

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);
Social0
  • 21
  • 1
  • 1
    Thanks a lot for your answer. I was having the same problem (video worked in Desktop and Android, but not iOS) and couldn't figure out what the problem was. Maybe this should be explained in this page, where their example code shows the opposite! ( play() before Texture.fromNetStream() ) --> http://gamua.com/blog/2015/07/starling-17/ – OMA Jul 31 '15 at 16:28