• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

video duration

Engaged ,
Oct 23, 2011 Oct 23, 2011

Copy link to clipboard

Copied

How to get video duration in as3 ?

TOPICS
ActionScript

Views

1.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Oct 27, 2011 Oct 27, 2011

You declared hours2, minutes2,etc. as Numbers but attempt to use them as Strings - hence the error.

Votes

Translate

Translate
LEGEND ,
Oct 24, 2011 Oct 24, 2011

Copy link to clipboard

Copied

NetStream invokes onMetaData() method - when it does - you can read video info including duration:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/NetStream.html?filter_f...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 25, 2011 Oct 25, 2011

Copy link to clipboard

Copied

function formatTime(t:int):String {

          var s:int = Math.round(t);

          var m:int = 0;

          if (s > 0) {

                    while (s > 59) {

                              m++;

                              s -= 60;

                    }

                    return String((m < 10 ? "0" : "") + m + ":" + (s < 10 ? "0" : "") + s);

          } else {

                    return "00:00";

          }

}

How to add hours to above script.

Format : HH:MM:SS

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 25, 2011 Oct 25, 2011

Copy link to clipboard

Copied

Use Date() and RegExp to do that. I have a tutorial on my blog:

http://as3-blog.net/?p=163

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 27, 2011 Oct 27, 2011

Copy link to clipboard

Copied

I changed this total duration of video.

but some issus

msg is

Scene 1, Layer 'Actions', Frame 1, Line 5091067: Implicit coercion of a value of type String to an unrelated type Number.

var newMeta:Object = new Object(); 

newMeta.onMetaData = onMetaData;

var vFrame:MovieClip=new MovieClip();

this.addChild(vFrame);

vFrame.addEventListener(Event.ENTER_FRAME, videoStatus);

function onMetaData(newMeta:Object):void 

  duration = newMeta.duration;

          var hours2:Number;

          var minutes2:Number;

          var seconds2:Number;

 

          var durminutes = duration/60;

                    hours2           = Math.floor(durmin/60);

          if (duration>=3600) {

                    minutes2 = Math.floor(durmin%60);

          } else {

                    minutes2 = Math.floor(duration/60);

          }

                    seconds2 = Math.floor(duration%60);

          if (hours2<10) {

                    hours2 = "0"+hours2;

          }

          if (minutes2<10) {

                    minutes2 = "0"+minutes2;

          }

          if (seconds2<10) {

                    seconds2 = "0"+seconds2;

          }

trace (hours2+":"+minutes2+":"+seconds2);

}

function videoStatus():void 

{

          amountLoaded = ns.bytesLoaded/ns.bytesTotal;

          controls.seekbar.loadBar.width = amountLoaded*330;

          controls.seekbar.scrubber.x = ns.time/duration*320;

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 27, 2011 Oct 27, 2011

Copy link to clipboard

Copied

You declared hours2, minutes2,etc. as Numbers but attempt to use them as Strings - hence the error.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 28, 2012 Mar 28, 2012

Copy link to clipboard

Copied

LATEST

Now total time fine, playing fine.

Thank you

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines