|
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
|
|
|
|
|
Hi All
the string value is:
strValue = "ABCD*XYZ";
I want to know the possition of sterik *
thank you
|
|
|
|
|
int pos=strValue.IndexOf("*"):
Luc Pattyn
|
|
|
|
|
Use something like:
int asteriskPosition = strValue.IndexOf("*");
This returns the index of the * in the string.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
thank you sir
|
|
|
|
|
I have a (simple) custom control, a NumericTextBox. This control allow to the user to type only numbers (0..9) inside.
I do this OnKeyPress and OnKeyDown events.
The problem is if the user do paste from Clipboard. I don't know how to deny "paste" operation if the content of the clipboard is not a number. (in each textbox you have an context menu, with "paste" function).
Or... better, not to deny the "paste" operation, but to add to the existing text of the textbox only numeric part of the clipboard content. (if the clipboard contains 12ad3 in my textbox to be added 123).
Any suggestion?
|
|
|
|
|
Hello,
I would suggest to validate the text in the OnTextChanged.
Store your valid nunber first and if the Conversion or better double.TryParse is not ok, insert the stored value again.
All the best,
Martin
|
|
|
|
|
why don't you use minimum and maximum properties??
life is study!!!
|
|
|
|
|
how to use this? min and max?
|
|
|
|
|
Hello! I working with 2005 MS Visual Studio. Wrote a function in c++: int func(LPWSTR lpszName){... return 0;}. I want to call it from c#: classname.func("name");, but compiler get error : Argument '1': cannot convert from 'string' to 'char*'. What can I do? Thanks
|
|
|
|
|
Your DllImport should just use "string" as the type:
[DllImport...]
public static extern void func(string name);
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
Hi all,
i'm trying to develope a windows service which will listen on a database table (Oracle database) , when a record updated ,the service will store it on another database . (Sql Server database)
the question is what is the best methodology to detect database update?
my idea is to run a query periodically and check the update ?
is anyone have a better solution ?
thanks.
Hosam Kamel
Software Developer
|
|
|
|
|
Why not use a trigger on the Oracle table to insert a notification into another table that a record has been updated. Then, your service would simply scan the notifications table and retrieve the details from here. Architecturally, you would want the item to be removed from the notifications table when it has SUCCESSFULLY saved into SQL Server.
To be honest though, you don't need a windows service to do this. All you need to do is create a DTS/SSIS package in SQL Server that does the read and save for you, and then schedule it to run as a scheduled database job.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi,
We can run the SQL Profiler and store the changes for checking updates
Regards,
Sylvester G
|
|
|
|
|
hi all,
how can i check that a word file is open or not through C#.
thanks
|
|
|
|
|
Try to open it exclusive. If an exception occurs, it's already open.
|
|
|
|
|
Using the interop assemblies.
How to open a document with word in all Office versions?
(Can't add more than 1 refernce to the Microsoft Word X.0 Object Library)
|
|
|
|
|
Hi All
Does anyone know the behaviour of the TcpClient.GetStream().Write()
on .NET CF 2.0 or any wrong in my code ?
I wrote the code listed at the end and found that even the network cable
was disconnected from my server, the TcpClient.GetStream().Write()
was not blocked. That was the code continued to run the line Console.WriteLine("Breakpoint 2");
When the program started, the following output produced:
Sending: 0000000001
Breakpoint 1
Breakpoint 2
Sending: 0000000002
Breakpoint 1
Breakpoint 2
< network cable disconnected >
Sending: 0000000003
Breakpoint 1
Breakpoint 2
Sending: 0000000004
Breakpoint 1
Breakpoint 2
< network cable re-connected >
Sending: 0000000005
Breakpoint 1
Net Error
Sending: 0000000005
Breakpoint 1
Breakpoint 2
The following is my code snippet
private void Connect()
{
}
private void SendMessageThread()
{
String message = String.Empty;
this.IsRunning = true;
while (this.IsRunning)
{
try
{
if ((this.IsRunning) && (!IsConnected)) Connect();
if ((this.IsRunning) && (IsConnected))
{
if (message == String.Empty)
{
message = DequeueManagerMessage();
}
if (message != String.Empty)
{
lock (this)
{
Console.WriteLine("Sending: {0}", message);
Byte[] data =
System.Text.Encoding.ASCII.GetBytes(
message.ToCharArray());
Console.WriteLine("Breakpoint 1");
tcpClient.GetStream().Write(data, 0, data.Length);
Console.WriteLine("Breakpoint 2");
message = String.Empty;
}
}
}
}
catch
{
Console.WriteLine("Net Error");
Disconnect();
}
}
this.IsRunning = false;
}
Antony
|
|
|
|
|
Hi All
Just one more finding. If I compile it as Win32 application, the same behaviour
occurred.
Can anyone advise what's wrong and the improvement ?
Regards
Antony
|
|
|
|
|
I need a working prototype for creating a connector between elements of a form without getting into Graphics.
Please let me know an algorith or a working prototype
Uday Denduluri
|
|
|
|
|
what do you mean with connector between elements ?
you want to link two controls by some means?
V.
I found a living worth working for, but haven't found work worth living for.
|
|
|
|
|
hi,
can anyone give me the naming conventions for variables in C#.
if anyone have please give me the list..
i'm just confused when going through the code, what is what in my code.
thanx,
nas
|
|
|
|
|
Googled:
http://msdn2.microsoft.com/en-us/library/ms229045.aspx[^]
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Naming Guidelines[^]
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
most important is that you stay consistant.
V.
I found a living worth working for, but haven't found work worth living for.
|
|
|
|