Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi...

before a had this question so someones help me!!!
but the answers wasn't answer of my question, i want to know the length of a music but this code give me the weight of a music (in bytes)...
OpenFileDialog dlgOpenFile = new OpenFileDialog();

            String filepath = "";
            string[] str;
            string nomeFich = "";
            dlgOpenFile.Filter = ("MP3 files (*.mp3)|*.mp3");

            if (dlgOpenFile.ShowDialog() == DialogResult.OK)
            {
                filepath = dlgOpenFile.FileName;

                long fileSize = 0;

                System.IO.FileInfo fi = new FileInfo(filepath);

                fileSize = fi.Length;

                progressBar1.Minimum = 0;

                progressBar1.Maximum = (int)fileSize;

                fileSize = fileSize / 1000000;

                for (int indice = 0; indice < fileSize; indice++)
                {
                    progressBar1.Value = indice;

                    SoundPlayer.URL = odf.FileName; 

                } 

Here fileSize give me the size of music (e.g 5667434)_in bytes_;
if this code is wrong what's the problem , if for this work we need another code what is it?

Good Luck!
Posted
Updated 14-Apr-11 21:58pm
v2

1 solution

Hi,
If you want the length of the audio file than you should reads it's underlying tags (for mp3 format its ID3 tags). There is a good library for this purpose: http://www.novell.com/products/linuxpackages/opensuse11.1/taglib-sharp.html[^]
Regards
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900