The following code requires the download of the
Windows Media Encoder SDK.
As I've mentioned before, the Windows Media Encoder makes life a lot easier for VB developers
working with audio files. However, the documentation for the SDK can be a bit sparse in
certain areas.
One thing that is not mentioned in the documentation is that Visual Basic cannot handle
encoding WMA files with a Variable Bit Rate (VBR) profile. VB has no problem encoding
WMAs with Constant Bit Rates, but not VBRs. So if you need to encode VBRs in Visual Basic,
you need to make a command line call to a .VBS (wmcmd.vbs) file that comes with the SDK.
For this tutorial, we will use the following VBR PRX (encoder Profile). Copy the text and
save it in the folder with your VB Application, naming it VBRProfile.prx:
Now add a module to your VB project, which will handle the calls to the command line:
Then add this code to your VB form to encode your audio file to a VBR WMA. The encoding object
can accept either an MP3 or WAV file. Make sure you include a fully qualified path to your
audio file.
Make sure you have placed the wmcmd.vbs file in the same folder as your VB application. Here
is the code for the vbs script (it comes with the SDK so you should already have it):
Related Links: Updating WMA files | Duration Times of Audio Files
Want to discuss this article, or other development issues? Visit our
message boards!
Or contact us directly with a comment or question on this article: click here ! |