none
mp3 length

    Question

  • 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 :)
    Saturday, February 07, 2009 10:45 AM

Answers

  • 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

    • Marked as answer by Harry Zhu Friday, February 13, 2009 11:16 AM
    Friday, February 13, 2009 11:16 AM

All replies