Is there some way to dynamically name files published in Flash Media server.
Several clients in an application will be publishing to FMS. They may start and stop recording several times, and I would like to append a time stamp (format: yy-mm-dd-hh-mm-ss) to the file name in main.asc.
For example the following files might be created by clients 1 and 2 using the ns.publish(myclientName);
command;
- client1's first recording client1_2011-01-01-22-47-01.flv
- client1's second recording client1_2011-01-01-22-54-55.flv
- client2's first recording client2_2011-01-01-22-59-34.flv
- client1's third recording client1_2011-01-01-22-04-12.flv
I don't want to use ns.publish(myClientName, "append");
. There needs to be a separate file for each publish session.
The best I can come up with is to use File.creationTime and File.renameTo() on applica开发者_运维知识库tion.onUnpublish() to add the timestamp when publishing has ended, but it it wouldn't be tolerant of an unexpected server outage.
Edit: Unknown to me and in conflict with the documentation, the Date object in Flash Media Server is not the one we know and love. It has no properties. For example
var currentTime = new Date();
trace("CurrentTime: " +currentTime.time);
prints
CurrentTime: undefined
Running
for (var prop in currentTime)
trace(prop);
prints nothing.
I was surprised and frustrated after an hour or so to learn this. Hope it helps someone.
currentTime.valueOf()
is timespan
精彩评论