Traitée mp3 length

  • Saturday, February 07, 2009 10:45 AM
     
     
    hi, i wounder if anyone could help me out of getting the length of a song, im working on a mp3 player(for fun) and it aint much without a trackbar and a label that shows the length.

    well if anyone wanna help me out, post some code :)

All Replies

  • Saturday, February 07, 2009 1:00 PM
     
     
    Hi!

    This will help: http://www.developerfusion.com/code/4684/read-mp3-tag-information-id3v1-and-id3v2/

    Regards,
    Lucian Baciu, http://studentclub.ro/lucians_weblog
  • Sunday, February 08, 2009 6:19 AM
     
     
    uhm hehe i need more help then that, i can get some stuffs to work but i cant get the length of the song... :/
  • Friday, February 13, 2009 11:16 AM
    Moderator
     
     Answered Has Code
    Hi,

    MCI can be used to get the length , the article has illustrate how to use it:
    http://dotnet.org.za/deon/pages/3057.aspx
    You can try the following code to get the file length.

    string str = @"D:\mus\withblank\nocturne.mp3";  
     
     
     
    string sCommand = "open \"" + str + "\" type mpegvideo alias MediaFile";   
     
    mciSendString(sCommand, null, 0, IntPtr.Zero);  //open the file
     
     
    StringBuilder sb=new StringBuilder(1000);  
     
    mciSendString("status MediaFile Length", sb, sb.Capacity, IntPtr.Zero); //query the length of the file 
     

      
    Best regards,
    Harry