-
FLV playtime / duration
How can I extract the playtime/duration from a flv File?
I figured it will be in the header after "64 75 72 61 74 69 6f 6e 00"(duration) when I opened a flv file in the hex editor. However, I have no idea how to convert the value that follows to a readable time
(using blitzbasic or php)
Or maybe I am on the wrong track
Last edited by Nobody6; 06-11-2008 at 09:13 PM.
-
Senior Member
i don't know what version of actionscript you're using. this is as2.0
if it's the real time in minute/seconds format you want. create a textfield movieclip and give the textfield an instance name flv_timer. The movieclip itself need not have an instance name. below is the script for the movieclips. it goes on the movieclip's timeline.
PHP Code:
onEnterFrame = function () {
MTime = _root.vd1.playheadTime;//where vd1 is the instance name for the flvPlayBack Component
hours = Math.floor(MTime/3600);
minutes = Math.floor((MTime/3600-hours)*60);
seconds = Math.floor(((MTime/3600-hours)*60-minutes)*60);
milli = Math.floor((Mtime-(seconds+(minutes*60)+(hours*3600)))*100);
if (seconds<10) {
seconds = "0"+seconds;
}
if (minutes<10) {
minutes = "0"+minutes;
}
flv_timer.text = minutes+":"+seconds;
};
for the duration (total time) of the flv, create another texfield movieclip, give the textfield an instance name flv_duration, and put this code on the timeline of this movieclip;
PHP Code:
onEnterFrame = function () {
MTime = _root.vd1.totalTime;//vd1 = instance name of flvPlayback
hours = Math.floor(MTime/3600);
minutes = Math.floor((MTime/3600-hours)*60);
seconds = Math.floor(((MTime/3600-hours)*60-minutes)*60);
milli = Math.floor((Mtime-(seconds+(minutes*60)+(hours*3600)))*100);
if (seconds<10) {
seconds = "0"+seconds;
}
if (minutes<10) {
minutes = "0"+minutes;
}
flv_duration.text = minutes+":"+seconds;
};
actually both codes are identical, the only difference is MTime, where when counting the time as it plays using playheadTime, and the other MTime counts the totalTime. I prefer to create 2 separate movieclips for placement reasons. These 2 scripts can be combined to display both in 1 textfield. This can also be scripted to calculate the percentage played of the duration which would be 100%. hope this helps.
Last edited by EQFlash; 06-11-2008 at 10:44 PM.
If you don't think you're going to like the answer, then don't ask the question.
-
Hi,
This is awesome, Can I use this code for an external swf as well.
Best,
Petra
-
Senior Member
hi petra, yes you can use it to time swf files. it would have to be adapted to time a swf though
If you don't think you're going to like the answer, then don't ask the question.
-
Thank you! Is there any what you can assist me with it? when i plugged in the code i got a Nan:Nan response in my textfield.
-
Senior Member
i'll throw something together for ya. Please don't rush me though, I have family medical issues to deal with at the moment.
If you don't think you're going to like the answer, then don't ask the question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|