Skip to main content
Participating Frequently
January 30, 2014
Question

as3 I need to play mp4 video! I use FileReference (ByteArray)

  • January 30, 2014
  • 2 replies
  • 2308 views

This code do not work:

data - ByteArray

var nc:NetConnection;

                              var ns:NetStream;

ns.appendBytes(data);

nc=new NetConnection();

                                        nc.connect(null);

                                        ns=new NetStream(nc);

                                        var video:Video = new Video();

                                        video.attachNetStream(ns);

                                        ns.play(null);    

addChild(video);

Help me!

This topic has been closed for replies.

2 replies

Inspiring
February 1, 2014

1. appendBytes understands FLV only by default.

2. In order to play mp4 (or any other than FLV format) you need to use appendBytesAction(NetStreamAppendBytesAction.RESET_BEGIN) so that Flash reads file correctly. This is quite a flaky proposition anyway.

3. appendBytes must be called after play(null) is called. Otherwise Flash throw an error.

Correct sequence:

     ns.play(null);

     ns.appendBytes(ba);

Incorrect sequence:

     ns.appendBytes(ba);

     ns.play(null);

kglad
Community Expert
Community Expert
January 30, 2014

where's data defined?

VovazverAuthor
Participating Frequently
January 31, 2014

I download video mp4 or 3gp file from local memory.

kglad
Community Expert
Community Expert
January 31, 2014

that's where your error is.  show the code that defines data.