Groups | Blog | Home
all groups > macromedia flash flashcom > february 2007 >

macromedia flash flashcom : How Do I Get Access to a Client's Streams



cteegarden
2/23/2007 2:11:35 AM
I'm using the default FLVPlayback server side application to provide access to
existing flash videos on the server. From reading and using the server admin
UI, I can see that each client gets a stream allocated with a random name
assigned by the server to handle the playback.

What I need to do is modify that server side app so that I can set the
onStatus property for the playback stream. The static method Stream.get()
would work - but only if I know the name of that client's stream. I can't seem
to figure out how to do that from within the server side application.

I've tried using the admin API from the onConnect() or onConnectAccept()
routine. I'm able to create a NetConnection to the admin port on the server
and invoke the call but the callback object is never invoked. It appears that
the admin API requires that it be executing in the context of a client side app
to work.

I've looked into the component facade and component objects but can't seem to
find anything that provides an example. Searching these forums and general
googling hasn't provided an answer either. Can anyone provide insight into how
I can obtain access to the Stream object associated with a new client?

thanks in advance,
Chris
Barry F
2/23/2007 5:41:40 PM
I think you are confusing the name of the client and the name of the stream.
The name of the stream is just the name of an FLV file saved under the
application streams directory (minus the .FLV extension).

The way to receive stream callbacks on a client-by-client basis is to give
each client his own unique stream, and then republish the original stream for
each client. For instance, suppose you have an FLV file on your server called
"foo.flv" that you want to publish:

application.onConnect = function(client, unique_id) {
client.readAccess = "/" + unique_id;
client.writeAccess = "";
application.acceptConnection(client);
Stream unique_stream = Stream.get(unique_id);
unique_stream.onStatus = function(info) { /*Your code here*/ };
unique_stream.onPlayStatus = function(info) { /*Your code here*/ };
unique_stream.play("foo", 0, -1);
};

The above code creates a new stream with a unique name, and then republishes
the "foo.flv" file to that stream. unique_id is a unique value generated by you
(e.g. a user name) and passed in by the client via
NetConnection.connect(server, unique_id);

Your player client then subscribes to his own stream with:
NetStream.play(unique_id, 0, -1);

The advantage to this approach is that you have control over the stream of
each individual client. You would not have this level of control if your
clients just subscribed directly to the "foo" stream.


Barry
AddThis Social Bookmark Button