# SDL\_Mixer - get music duration

**URL:** <https://discourse.libsdl.org/t/sdl-mixer-get-music-duration/19558>\
**Category:** SDL Development\
**Created:** [April 27, 2013, 3:41pm UTC](https://discourse.libsdl.org/t/sdl-mixer-get-music-duration/19558 "2013-04-27T15:41:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Krzysztof](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/k/ed655f/32.png) [@Krzysztof](https://discourse.libsdl.org/u/Krzysztof)\
**Post date:** [April 27, 2013, 3:41pm UTC](https://discourse.libsdl.org/t/sdl-mixer-get-music-duration/19558/1 "2013-04-27T15:41:43Z")

</div>

Hi,

I see SetPosition function but how I get know what is a total music length  
of playing mp3?

Regards

---

<div class="post-metadata">

**Author:** ![Christian\_Leger](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/c/ecae2f/32.png) [@Christian\_Leger](https://discourse.libsdl.org/u/Christian_Leger)\
**Post date:** [April 27, 2013, 4:36pm UTC](https://discourse.libsdl.org/t/sdl-mixer-get-music-duration/19558/2 "2013-04-27T16:36:32Z")

</div>

Is it proportional to the size and bitrate of the file? Maybe experimenting  
with seeking to various byte locations could be compared to song position?  
Perhaps you would find that they match up nicely.On Sat, Apr 27, 2013 at 11:41 AM, Krzysztof wrote:

> Hi,
> 
> I see SetPosition function but how I get know what is a total music length  
> of playing mp3?
> 
> Regards
> 
> * * *
> 
> SDL mailing list  
> SDL at [lists.libsdl.org](http://lists.libsdl.org)  
> [http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)

---

<div class="post-metadata">

**Author:** ![Sik\_the\_hedgehog](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/db5fbb/32.png) [@Sik\_the\_hedgehog](https://discourse.libsdl.org/u/Sik_the_hedgehog)\
**Post date:** [April 27, 2013, 4:55pm UTC](https://discourse.libsdl.org/t/sdl-mixer-get-music-duration/19558/3 "2013-04-27T16:55:02Z")

</div>

Then you realize MP3 supports variable bitrate…

2013/4/27, Christian Leger \<chrism.leger at [gmail.com](http://gmail.com)\>:\> Is it proportional to the size and bitrate of the file? Maybe experimenting

> with seeking to various byte locations could be compared to song position?  
> Perhaps you would find that they match up nicely.
> 
> On Sat, Apr 27, 2013 at 11:41 AM, Krzysztof wrote:
> 
> > Hi,
> > 
> > I see SetPosition function but how I get know what is a total music  
> > length  
> > of playing mp3?
> > 
> > Regards
> > 
> > * * *
> > 
> > SDL mailing list  
> > SDL at [lists.libsdl.org](http://lists.libsdl.org)  
> > [http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)

---

<div class="post-metadata">

**Author:** ![slouken](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/ec9cab/32.png) [@slouken](https://discourse.libsdl.org/u/slouken)\
**Post date:** [April 30, 2013, 6:18am UTC](https://discourse.libsdl.org/t/sdl-mixer-get-music-duration/19558/4 "2013-04-30T06:18:07Z")

</div>

It doesn’t look like that’s in the API. You should be able to add it  
though, just look at the implementation of Mix\_SetMusicPosition(), and see  
how you would find the maximum position.On Sat, Apr 27, 2013 at 8:41 AM, Krzysztof wrote:

> Hi,
> 
> I see SetPosition function but how I get know what is a total music length  
> of playing mp3?
> 
> Regards
> 
> * * *
> 
> SDL mailing list  
> SDL at [lists.libsdl.org](http://lists.libsdl.org)  
> [http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)
