Click here to Skip to main content
15,914,066 members
Home / Discussions / C#
   

C#

 
QuestionPicture box and KeyDown event with arrow keys Pin
--==PP==--25-Jan-07 5:24
--==PP==--25-Jan-07 5:24 
AnswerRe: Picture box and KeyDown event with arrow keys Pin
ednrgc25-Jan-07 5:44
ednrgc25-Jan-07 5:44 
GeneralRe: Picture box and KeyDown event with arrow keys Pin
--==PP==--25-Jan-07 6:04
--==PP==--25-Jan-07 6:04 
GeneralRe: Picture box and KeyDown event with arrow keys Pin
ednrgc25-Jan-07 6:06
ednrgc25-Jan-07 6:06 
GeneralRe: Picture box and KeyDown event with arrow keys Pin
--==PP==--25-Jan-07 6:27
--==PP==--25-Jan-07 6:27 
AnswerRe: Picture box and KeyDown event with arrow keys Pin
bobsugar22226-Jan-07 0:08
bobsugar22226-Jan-07 0:08 
QuestionAbstract Base Class Pin
Russell Jones25-Jan-07 3:37
Russell Jones25-Jan-07 3:37 
AnswerRe: Abstract Base Class Pin
Steve Hansen25-Jan-07 3:57
Steve Hansen25-Jan-07 3:57 
GeneralRe: Abstract Base Class Pin
Russell Jones25-Jan-07 4:08
Russell Jones25-Jan-07 4:08 
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 

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.