View Full Version : displaying the complete time and the time passed on a flv
exactpixel
12-19-2003, 05:58 PM
hello all,
i'm trying to get the lenght of a stream(flv) and display it. get the amount of time that has played on the stream and display that, it will look like this in the end :
01:32/09:45
has any one done this and what would be the best way to go about it? i already have a .asc file that grabs the stream.length and brings it back into flash in secs, but that's as far as i've gotton, and i want to go about this the right way. am i going to create a getTimer() object or is there a clientside script that will accurately display the stream.
thanks,
also, how would i go about trimming the extra characters off of the seconds?
exactpixel
12-22-2003, 04:06 PM
ok, i've gotten the total time, but for some reason, NetStream.time() does not work :( it just returns "undefined"?
talk'n to myseeaeaalffffff....
exactpixel
12-22-2003, 04:29 PM
bad syntax was the villan.
artane
03-31-2004, 07:17 PM
hi guys,
What is the simplest way to display the time according to my flashcom server.
Do I have to add something to my main.asc file?
On the client side, does my movie need a dynamic text box that references a variable etc?
I just need to display the current server time, plain and simple.
Thank-you very much,
artane
exactpixel
04-02-2004, 11:23 AM
put this in your main.asc file.
application.acceptConnection(clientObj);
Client.prototype.sendInfo = function(c){
return Stream.length(c);
trace(Stream.length);
}
}
not sure if these tags work...
put this in the fla that plays yo video:
myInputStream = new NetStream (nc);
myInputStream.onResult = function (sL)
{
this.duration = sL;
//some math to shell it out for you
exactTime = Math.floor (sl);
myInputStream.duration = Math.floor (sl);
minute = Math.floor (exactTime/60);
seconds = Math.floor (exactTime%60);
//trace ("THIS IS THE SL OBJECT RETURN: "+exactTime);
//trace ("THIS IS THE TOTAL: ="+minute+":"+seconds);
};
yup, hope that helps
xbrotherx
11-01-2004, 05:08 AM
exactpixel,
could you please explain your code above. I am struggling severly with talking back and forth between the server side code and client side and I am trying to accomplish something similar to your first post on this thread concerning elapsed time and total time.
I try to just put an application.acceptConnection = function() method in my .asc file and I continue to get errors saying there is a syntax error...missing ; before statement. Well why should there be a semi colon before that method declaration. Makes no sense.
Anyway, any help would be appreciated.
To get back on the original topic issue... I am interested in getting the length of a recorded (in my case audio but assume it works the same for video) flash stream file.
The FCS documentation comes with the following example (slightly altered though):
For the .fla file, this code (php formatting seems to work nicely)
streamFileName = "streamname"; // without .flv ofcourse
getInfo(streamFileName);
function getInfo(myStreamName)
{
nc.call("sendInfo", new MyResultSetName(), myStreamName);
}
function MyResultSetName()
{
this.onResult = function(retVal)
{
_root.streamlength = retVal;
};
this.onStatus = function(info)
{
trace("Level: " + info.level + " Code: " + info.code);
// process error object
};
}
And the main.asc part
application.onAppStart = function()
{
trace("::: Application has started :::");
}
application.onConnect = function(client)
{
application.acceptConnection(client);
// Add methods
Client.prototype.sendInfo = function(name) {
var slen = Stream.length(name);
trace("slen: " + slen);
return slen;
};
}
(corrected the typo in the prototype function, they used client.prototype instead of Client.prototype which didn't seem to work, go macromedia)..
either ways... it would have been nice if they put a fully working example for this code in the documentation, as this partial example got me stuck, eventhough it does work... if you want to trace that is.
The getInfo() function calls the prototype function sendInfo on the server, and the result is stored in a (new) object.
This new object however, also has to wait for the FCS to respond to the call, so it uses '.onresult' and then sets _root.streamlength
So I ended up with jumping in timelines after all..
My Frame 1 has the code:
stop();
hostFCS = "localhost";
nc=new NetConnection();
nc.connect("rtmp://"+hostFCS+"/ak-cms/audio");
streamLength = "";
nc.onStatus = function(info)
{
if(info.code == "NetConnection.Connect.Success")
{
filename = "audiotestbestand";
debugTxt = "Get length " + filename;
getInfo(filename);
}
}
function getInfo(myStreamName)
{
nc.call("sendInfo", new MyResultSetName(), myStreamName);
}
function MyResultSetName()
{
this.onResult = function(retVal)
{
streamLength = retVal;
gotoAndStop("outputInfo");
};
this.onStatus = function(info)
{
trace("Level: " + info.level + " Code: " + info.code);
// process error object
};
}
and Frame 2, with label outputInfo has:
stop();
msg = "Length of " + filename + " = " + streamLength;
debugTxt = msg;
where debugTxt is a textfield with var-name debugTxt.
hope this helps someone.. got me stuck for a few hours on how to handle the value return by the nc.call.. jumping seems to work.
exactpixel
11-10-2004, 01:35 AM
Sorry, just got the email notification. Did that help you at all?
ep
perrelet
09-17-2007, 10:27 AM
myNetStream.onMetaData = function(infoObject:Object) {
var duration = infoObject.duration;
}
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.