Playing Music in VB.Net application [modified]
-
I am trying to play music in my application using command My.Computer.Audio.Play (complete path , AudioPlayMode.Background). The file I am trying to use is a wavefile(.wmv). However when the command is executed an exception is thrown saying The specified file is not PCM type wavefile. Please help regarding what i am supposed to do. I am using Visual Studio 2008.
modified on Wednesday, May 6, 2009 2:40 PM
-
I am trying to play music in my application using command My.Computer.Audio.Play (complete path , AudioPlayMode.Background). The file I am trying to use is a wavefile(.wmv). However when the command is executed an exception is thrown saying The specified file is not PCM type wavefile. Please help regarding what i am supposed to do. I am using Visual Studio 2008.
modified on Wednesday, May 6, 2009 2:40 PM
It's quite plain. The file you're trying to play is not in the correct format. Just because the file extension is WMV doesn't mean that the audio is encoded the same as every other WMV. The audio in each file, no matter what the extension, is encoded using different codecs, compressor/decompressors. But, there is a standard format called PCM (Pulse Coded Modulation) that is kind of like the Text file of the audio world. It's audio that is not compressed at all. This is the format that the Audio.Play method supports. It cannot play audio that is compressed. You have to use some kind of tool to create a new file with the audio uncompressed.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
It's quite plain. The file you're trying to play is not in the correct format. Just because the file extension is WMV doesn't mean that the audio is encoded the same as every other WMV. The audio in each file, no matter what the extension, is encoded using different codecs, compressor/decompressors. But, there is a standard format called PCM (Pulse Coded Modulation) that is kind of like the Text file of the audio world. It's audio that is not compressed at all. This is the format that the Audio.Play method supports. It cannot play audio that is compressed. You have to use some kind of tool to create a new file with the audio uncompressed.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008Any possible different method I can use the sound-file in my application. Also guide me as how i can come to know the compression/decompression technique. Thank You.
-
Any possible different method I can use the sound-file in my application. Also guide me as how i can come to know the compression/decompression technique. Thank You.
Ishaan Karnik wrote:
Any possible different method I can use the sound-file in my application.
You can use a Windows Media Player component. Drop one from the ToolBox onto your form and you can use that to play the files.
Ishaan Karnik wrote:
Also guide me as how i can come to know the compression/decompression technique.
It's not technique you use in your code. Google for "what is a codec" for more information.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
Ishaan Karnik wrote:
Any possible different method I can use the sound-file in my application.
You can use a Windows Media Player component. Drop one from the ToolBox onto your form and you can use that to play the files.
Ishaan Karnik wrote:
Also guide me as how i can come to know the compression/decompression technique.
It's not technique you use in your code. Google for "what is a codec" for more information.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008Sir, I couldnot find a Media Player Component in my toolbox. Please guide me for the same. Thank You
-
Sir, I couldnot find a Media Player Component in my toolbox. Please guide me for the same. Thank You
Then add it. Right-click the ToolBox, then click on Choose Items... In the dialog that comes up, click on the COM tab, scroll down the list until you find Windows Media Player and check the box next to it. Click on OK, and you're done.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
I am trying to play music in my application using command My.Computer.Audio.Play (complete path , AudioPlayMode.Background). The file I am trying to use is a wavefile(.wmv). However when the command is executed an exception is thrown saying The specified file is not PCM type wavefile. Please help regarding what i am supposed to do. I am using Visual Studio 2008.
modified on Wednesday, May 6, 2009 2:40 PM