4

I have a netConnection connected to a Flash Media Server. I am trying to use the new appendBytes function from Flash Player 10.1 to stream a local FLV file to FMS. I'm having issues however... Documentation I get online

function playFile(data:ByteArray):void
{
// data is bytearray data from an already loaded FileReference object
    netStream.play(null);
    netStream.appendBytesAction(NetStreamAppendBytesAction.RESET_BEGIN);
    netStream.appendBytes(data);
}

However, I'm getting an error with the appendBytesAction and appendBytes. The error is: Error #2004: One of the parameters is invalid....

TypeError: Error #2004: One of the parameters is invalid.

Any ideas? Thanks

K2xL
  • 9,730
  • 18
  • 64
  • 101

1 Answers1

3

You can't use appendBytes successfully when your stream's NetConnection is connected to anything else than "null". From the documentation of appendBytes method at http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/NetStream.html#appendBytes%28%29:

Passes a ByteArray into a NetStream for playout. Call this method on a NetStream in "Data Generation Mode". To put a NetStream into Data Generation Mode, call NetStream.play(null) on a NetStream created on a NetConnection connected to null. Calling appendBytes() on a NetStream that isn't in Data Generation Mode is an error and raises an exception.

This almost certainly implies that what Adobe calls "Data Generation Mode" will not be available on a connection object connected to say, a Flash Media Server instance.

Armen Michaeli
  • 8,625
  • 8
  • 58
  • 95
  • 1
    Yes, just found read that this morning. Sort of lame... Don't understand why they wouldn't allow appendBytes on a NetStream out of data generation mode.. Would save people from having to use ManyCam and Soundflower when trying to stream a video file online. – K2xL Oct 31 '11 at 14:24
  • 1
    Had the same issue, absolutely shocking this isn't allowed. As others hinted at, it's likely an arbitrary limitation put in place for business reasons :( – Rafael Rivera Mar 10 '12 at 08:06