Click here to Skip to main content
15,900,512 members
Home / Discussions / C#
   

C#

 
AnswerRe: Abstract Base Class Pin
Colin Angus Mackay25-Jan-07 4:28
Colin Angus Mackay25-Jan-07 4:28 
AnswerRe: Abstract Base Class Pin
Marc Clifton25-Jan-07 4:33
mvaMarc Clifton25-Jan-07 4:33 
AnswerRe: Abstract Base Class Pin
ednrgc25-Jan-07 5:47
ednrgc25-Jan-07 5:47 
AnswerRe: Abstract Base Class Pin
Ravi Bhavnani25-Jan-07 11:41
professionalRavi Bhavnani25-Jan-07 11:41 
Questionhow to get the duration of an mp3 file Pin
Sivaprasad C25-Jan-07 2:57
Sivaprasad C25-Jan-07 2:57 
AnswerRe: how to get the duration of an mp3 file Pin
Judah Gabriel Himango25-Jan-07 5:36
sponsorJudah Gabriel Himango25-Jan-07 5:36 
AnswerRe: how to get the duration of an mp3 file Pin
ComCoderCsharp25-Jan-07 7:12
ComCoderCsharp25-Jan-07 7:12 
AnswerRe: how to get the duration of an mp3 file Pin
greycrow25-Jan-07 8:00
greycrow25-Jan-07 8:00 
If I oversimplify this or you all ready know parts of this, I appologize. But here goes...

MP3 files are made up of a bunch of music sections, each having a header. At the end of the
file is a TAG 128 bytes long.

The Gist of getting the duration of an MP3 is to first get the size of the file, then subtract
128 bytes for the TAG. Divide the number of remaining "Bits" in the file by the bitrate.

So to get the file length:
.
.
using System.IO;
.
.
FileStream MP3File;
.
MP3File = new FileStream("C:\\mySong.mp3", FileMode.Open);
.
FileLength = MP3File.Length; // gives file length in bytes
.
And for the duration:
.
Duration = ((FileLength - 128) * 8) / bitrate; //gives duration in seconds
.
The problem now lies in getting the bitrate. If you know all your files are say 128kbits/sec
you can cheat an get a pretty good estimate. So your formula would be.

Duration = ((FileLength - 128) * 8) / (1024*128);

The problem is real MP3 files can have different bitrates within individiual song blocks.
So it would be neccessary to read each block header for the bitrate and then add everything
up at the end. Rather a tedious exercise.

Hope that helps a bit

greycrow



QuestionI need to know the possition of Sterik in string value Pin
M Riaz Bashir25-Jan-07 2:42
M Riaz Bashir25-Jan-07 2:42 
AnswerRe: I need to know the possition of Sterik in string value Pin
Luc Pattyn25-Jan-07 2:52
sitebuilderLuc Pattyn25-Jan-07 2:52 
AnswerRe: I need to know the possition of Sterik in string value Pin
Pete O'Hanlon25-Jan-07 2:54
mvePete O'Hanlon25-Jan-07 2:54 
GeneralRe: I need to know the possition of Sterik in string value Pin
M Riaz Bashir25-Jan-07 3:08
M Riaz Bashir25-Jan-07 3:08 
QuestionClipboard Monitoring Pin
zeltera25-Jan-07 2:23
zeltera25-Jan-07 2:23 
AnswerRe: Clipboard Monitoring Pin
Martin#25-Jan-07 2:31
Martin#25-Jan-07 2:31 
AnswerRe: Clipboard Monitoring Pin
Seishin#25-Jan-07 3:16
Seishin#25-Jan-07 3:16 
GeneralRe: Clipboard Monitoring Pin
zeltera25-Jan-07 3:29
zeltera25-Jan-07 3:29 
Questioncant convert c# type string to c++ type char* Pin
Tsvi Girsh25-Jan-07 2:00
Tsvi Girsh25-Jan-07 2:00 
AnswerRe: cant convert c# type string to c++ type char* Pin
Marc Clifton25-Jan-07 4:32
mvaMarc Clifton25-Jan-07 4:32 
Questiondatabase watcher ... need suggestions !! Pin
eng_Hosam Kamel25-Jan-07 1:51
eng_Hosam Kamel25-Jan-07 1:51 
AnswerRe: database watcher ... need suggestions !! Pin
Pete O'Hanlon25-Jan-07 2:21
mvePete O'Hanlon25-Jan-07 2:21 
AnswerRe: database watcher ... need suggestions !! Pin
Sylvester george25-Jan-07 2:23
Sylvester george25-Jan-07 2:23 
Questioncheck whether word file is open or not Pin
praveen pandey25-Jan-07 1:45
praveen pandey25-Jan-07 1:45 
AnswerRe: check whether word file is open or not Pin
ednrgc25-Jan-07 5:49
ednrgc25-Jan-07 5:49 
QuestionOpen word document Pin
zt.Prog25-Jan-07 1:36
zt.Prog25-Jan-07 1:36 
QuestionNetwork programming problem Pin
Antony Lee25-Jan-07 1:26
Antony Lee25-Jan-07 1:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.