<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Calculating duration on mp3s in AS3</title>
	<atom:link href="http://www.stevensacks.net/2008/12/02/calculating-duration-on-mp3s-in-as3/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stevensacks.net/2008/12/02/calculating-duration-on-mp3s-in-as3/</link>
	<description>Adobe, Flash, Flex, AIR, Technology</description>
	<lastBuildDate>Thu, 18 Mar 2010 22:50:52 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: rob</title>
		<link>http://www.stevensacks.net/2008/12/02/calculating-duration-on-mp3s-in-as3/comment-page-1/#comment-18563</link>
		<dc:creator>rob</dc:creator>
		<pubDate>Sun, 17 Jan 2010 20:03:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.stevensacks.net/?p=307#comment-18563</guid>
		<description>Hi! The code works, but not when I load a MP3. If a trace the sound.length it&#039;s display an increasing value of the length until the sound finished loading. 

I want to start playing the sound while its&#039;s loading and show the position of the sound in a mc.

Is it possible?</description>
		<content:encoded><![CDATA[<p>Hi! The code works, but not when I load a MP3. If a trace the sound.length it&#039;s display an increasing value of the length until the sound finished loading. </p>
<p>I want to start playing the sound while its&#039;s loading and show the position of the sound in a mc.</p>
<p>Is it possible?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: marpies</title>
		<link>http://www.stevensacks.net/2008/12/02/calculating-duration-on-mp3s-in-as3/comment-page-1/#comment-11833</link>
		<dc:creator>marpies</dc:creator>
		<pubDate>Tue, 16 Jun 2009 13:33:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.stevensacks.net/?p=307#comment-11833</guid>
		<description>Amazing, working so nicely!

Thanks so much Steven!</description>
		<content:encoded><![CDATA[<p>Amazing, working so nicely!</p>
<p>Thanks so much Steven!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Isuru</title>
		<link>http://www.stevensacks.net/2008/12/02/calculating-duration-on-mp3s-in-as3/comment-page-1/#comment-9099</link>
		<dc:creator>Isuru</dc:creator>
		<pubDate>Fri, 27 Mar 2009 06:33:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.stevensacks.net/?p=307#comment-9099</guid>
		<description>its work on localy but not in server</description>
		<content:encoded><![CDATA[<p>its work on localy but not in server</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug</title>
		<link>http://www.stevensacks.net/2008/12/02/calculating-duration-on-mp3s-in-as3/comment-page-1/#comment-9065</link>
		<dc:creator>Doug</dc:creator>
		<pubDate>Thu, 26 Mar 2009 04:28:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.stevensacks.net/?p=307#comment-9065</guid>
		<description>thanks steven &amp; dudan, perfect!</description>
		<content:encoded><![CDATA[<p>thanks steven &amp; dudan, perfect!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dudan</title>
		<link>http://www.stevensacks.net/2008/12/02/calculating-duration-on-mp3s-in-as3/comment-page-1/#comment-8413</link>
		<dc:creator>dudan</dc:creator>
		<pubDate>Fri, 27 Feb 2009 10:00:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.stevensacks.net/?p=307#comment-8413</guid>
		<description>This code works nicely, cheers!

I found it a bit fiddly trying to work out the track time correctly, so here it is for anybody else:

var Milliseconds:Number = (music.bytesTotal / (music.bytesLoaded / music.length));

var Minutes:uint = Math.floor(Milliseconds/60000);
var Seconds:uint = (Milliseconds%60000);
var SecondsTens:uint = Math.floor(Seconds/10000);

Seconds = Math.ceil(Seconds%10000)
Seconds /= 1000;

trace(Minutes + &quot;:&quot; + SecondsTens + &quot;&quot; + Seconds);

dudan</description>
		<content:encoded><![CDATA[<p>This code works nicely, cheers!</p>
<p>I found it a bit fiddly trying to work out the track time correctly, so here it is for anybody else:</p>
<p>var Milliseconds:Number = (music.bytesTotal / (music.bytesLoaded / music.length));</p>
<p>var Minutes:uint = Math.floor(Milliseconds/60000);<br />
var Seconds:uint = (Milliseconds%60000);<br />
var SecondsTens:uint = Math.floor(Seconds/10000);</p>
<p>Seconds = Math.ceil(Seconds%10000)<br />
Seconds /= 1000;</p>
<p>trace(Minutes + &#034;:&#034; + SecondsTens + &#034;&#034; + Seconds);</p>
<p>dudan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steven Sacks</title>
		<link>http://www.stevensacks.net/2008/12/02/calculating-duration-on-mp3s-in-as3/comment-page-1/#comment-6735</link>
		<dc:creator>Steven Sacks</dc:creator>
		<pubDate>Wed, 10 Dec 2008 05:06:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.stevensacks.net/?p=307#comment-6735</guid>
		<description>Unfortunately, as I found out from the Flash player team at MAX, iTunes uses its own version of ID3v2 that Flash cannot detect so it never fires an ID3 event nor can it be read via the ID3 class.

So, for reliable ID3 access, you should use metaphile.

However, not all mp3s have useful ID3 data, so when you&#039;re loading mp3s that are not in your control, this estimation is as good as it gets, and it&#039;s pretty damn good.  I&#039;ve tested it on a bunch of mp3s from Seeqpod and it works great.</description>
		<content:encoded><![CDATA[<p>Unfortunately, as I found out from the Flash player team at MAX, iTunes uses its own version of ID3v2 that Flash cannot detect so it never fires an ID3 event nor can it be read via the ID3 class.</p>
<p>So, for reliable ID3 access, you should use metaphile.</p>
<p>However, not all mp3s have useful ID3 data, so when you&#039;re loading mp3s that are not in your control, this estimation is as good as it gets, and it&#039;s pretty damn good.  I&#039;ve tested it on a bunch of mp3s from Seeqpod and it works great.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patrick Matte</title>
		<link>http://www.stevensacks.net/2008/12/02/calculating-duration-on-mp3s-in-as3/comment-page-1/#comment-6734</link>
		<dc:creator>Patrick Matte</dc:creator>
		<pubDate>Wed, 10 Dec 2008 04:47:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.stevensacks.net/?p=307#comment-6734</guid>
		<description>There are some id3 editors that will automatically add a length property to the id3 tag. Then you can get that value from the id3 event dispatched by the sound object.</description>
		<content:encoded><![CDATA[<p>There are some id3 editors that will automatically add a length property to the id3 tag. Then you can get that value from the id3 event dispatched by the sound object.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steven Sacks</title>
		<link>http://www.stevensacks.net/2008/12/02/calculating-duration-on-mp3s-in-as3/comment-page-1/#comment-6555</link>
		<dc:creator>Steven Sacks</dc:creator>
		<pubDate>Wed, 03 Dec 2008 06:13:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.stevensacks.net/?p=307#comment-6555</guid>
		<description>@Matt - It&#039;s accurate to within a few seconds before 5 seconds, and by 5-7 seconds it&#039;s within a second.  After 10 seconds, you&#039;re within a few hundred milliseconds.  Suffice to say, it&#039;s accurate enough to be fractions of pixels on scrub bars from the start.  You won&#039;t be able to see it.  If you have a duration field, it might jump a little at the beginning, but it&#039;s not too noticable and it&#039;s over quickly enough.

@Phillip - My way really works, but as you mentioned, it only works with CBR, and might only work with 16/44 but &lt;a href=&quot;http://www.stevensacks.net/2008/08/07/bug-with-sound-channel-position-and-mp3s-less-than-128kbps/&quot; rel=&quot;nofollow&quot;&gt;non 16/44 have issues anyway&lt;/a&gt;.  VBRs have never really worked with Flash anyway.  They either work just fine, or they end up triggering SoundComplete before they&#039;re actually complete, or just stopping during playback altogether.  FP10 allows you bring in the mp3 as a byte stream, so theoretically (I haven&#039;t tested it), you can finally play VBRs in Flash with some reliability.</description>
		<content:encoded><![CDATA[<p>@Matt &#8211; It&#039;s accurate to within a few seconds before 5 seconds, and by 5-7 seconds it&#039;s within a second.  After 10 seconds, you&#039;re within a few hundred milliseconds.  Suffice to say, it&#039;s accurate enough to be fractions of pixels on scrub bars from the start.  You won&#039;t be able to see it.  If you have a duration field, it might jump a little at the beginning, but it&#039;s not too noticable and it&#039;s over quickly enough.</p>
<p>@Phillip &#8211; My way really works, but as you mentioned, it only works with CBR, and might only work with 16/44 but <a href="http://www.stevensacks.net/2008/08/07/bug-with-sound-channel-position-and-mp3s-less-than-128kbps/" rel="nofollow">non 16/44 have issues anyway</a>.  VBRs have never really worked with Flash anyway.  They either work just fine, or they end up triggering SoundComplete before they&#039;re actually complete, or just stopping during playback altogether.  FP10 allows you bring in the mp3 as a byte stream, so theoretically (I haven&#039;t tested it), you can finally play VBRs in Flash with some reliability.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phillip Kerman</title>
		<link>http://www.stevensacks.net/2008/12/02/calculating-duration-on-mp3s-in-as3/comment-page-1/#comment-6554</link>
		<dc:creator>Phillip Kerman</dc:creator>
		<pubDate>Wed, 03 Dec 2008 05:14:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.stevensacks.net/?p=307#comment-6554</guid>
		<description>My brain is hurting thinking about whether your way really works.  Seems like if you know the bitrate of the mp3 and it&#039;s CBR (not VBR) then you could just divide the bytes total by the bitrate to get a good duration. 

I&#039;ll probably wake up in the middle of the night have an epiphany...  what the heck is Flash&#039;s duration reporting anyway?  I wonder if the correct info is in the file&#039;s header.</description>
		<content:encoded><![CDATA[<p>My brain is hurting thinking about whether your way really works.  Seems like if you know the bitrate of the mp3 and it&#039;s CBR (not VBR) then you could just divide the bytes total by the bitrate to get a good duration. </p>
<p>I&#039;ll probably wake up in the middle of the night have an epiphany&#8230;  what the heck is Flash&#039;s duration reporting anyway?  I wonder if the correct info is in the file&#039;s header.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Przybylski</title>
		<link>http://www.stevensacks.net/2008/12/02/calculating-duration-on-mp3s-in-as3/comment-page-1/#comment-6547</link>
		<dc:creator>Matt Przybylski</dc:creator>
		<pubDate>Tue, 02 Dec 2008 21:29:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.stevensacks.net/?p=307#comment-6547</guid>
		<description>Steven,
Without having tried this myself, how accurate is it when compared to what you get when the sound is actually loaded?</description>
		<content:encoded><![CDATA[<p>Steven,<br />
Without having tried this myself, how accurate is it when compared to what you get when the sound is actually loaded?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
