 |
|
 |
hello,
I'm trying to find out how to play wave files stored in a connected access database.
How can I do this please?
I tried the code I found from this link: http://www.aboutmydot.net/index.php/play-wav-file-in-vbnet
-----------------------------------------------------------------------
Dim Sound As New System.Media.SoundPlayer()
Sound.SoundLocation = "your path to the .wav file" 'ex.: c:\mysound.wav Sound.Load() Sound.Play()
-----------------------------------------------------------------------
It was ok, but I don't want the path to the .wav file to necessarily start from c:\ since I'm hoping to have this project used on a different machine, meaning if I link it to specific path it would not play on a different machine.
So instead of something like: "C:\Documents and Settings\User\My Documents\Project\Sounds\mysound.wav"
as the link to the file, in the database field(eg.sWord)I made it short to be like:
\Sounds\mysound.wav
since the access file would also be in the folder Project, so that it could easily locate the wav file.
Therefore within the code instead of
Sound.SoundLocation = "your path to the .wav file" 'ex.: c:\mysound.wav
I made it
Sound.SoundLocation = SWordTextbox.Text where SWord.Textbox is the field in the database having the link to the wav file and therefore it's text property assigns the link to the attribute .SoundLocation.
I hope I've explained better, I'm kind of new to VB.net. Any help will be greatly appreciated.
Thanks.
modified on Friday, July 3, 2009 7:22 AM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Great article and explanation. 
Do you know a way to select the device to use for audio playing (other than changing the default device in control panel)?
Thanks Claudio
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
|
 |
|
 |
You'll have to extend the code yourself.
This can be done by using the same API winmm.dll that is being used. Simply add some more declarations, and work out some additional methods.
Here are just a few, I'll suggest you research the API at msdn.microsoft.com
Private Declare Function waveOutOpen Lib "winmm.dll" Alias "waveOutOpen" (ByVal lphWaveOut As Long, ByVal uDeviceID As Long, ByVal lpFormat As WAVEFORMATEX, ByVal dwCallback As Long, ByVal dwInstance As Long, ByVal dwFlags As Long) As Long Private Declare Function waveOutWrite Lib "winmm.dll" Alias "waveOutWrite" (ByVal hWaveOut As Long, ByVal lpWaveOutHdr As WAVEHDR, ByVal uSize As Long) As Long Private Declare Function waveOutPause Lib "winmm.dll" Alias "waveOutPause" (ByVal hWaveOut As Long) As Long Private Declare Function waveOutRestart Lib "winmm.dll" Alias "waveOutRestart" (ByVal hWaveOut As Long) As Long Private Declare Function waveOutSetPitch Lib "winmm.dll" Alias "waveOutSetPitch" (ByVal hWaveOut As Long, ByVal dwPitch As Long) As Long Private Declare Function waveOutGetPosition Lib "winmm.dll" Alias "waveOutGetPosition" (ByVal hWaveOut As Long, ByVal lpInfo As MMTIME, ByVal uSize As Long) As Long
' Management of errors. Private Declare Function waveOutGetErrorText Lib "winmm.dll" Alias "waveInGetErrorTextA" (ByVal err As Long, ByVal lpText As String, ByVal uSize As Long) As Long
Private Declare Function waveOutClose Lib "winmm.dll" Alias "waveOutClose" (ByVal hWaveOut As Long) As Long Private Declare Function waveOutGetID Lib "winmm.dll" Alias "waveOutGetID" (ByVal hWaveOut As Long, ByVal lpuDeviceID As Long) As Long Private Declare Function waveOutGetNumDevs Lib "winmm.dll" Alias "waveOutGetNumDevs" () As Long Private Declare Function waveOutPrepareHeader Lib "winmm.dll" Alias "waveOutPrepareHeader" (ByVal hWaveOut As Long, ByVal lpWaveOutHdr As WAVEHDR, ByVal uSize As Long) As Long Private Declare Function waveOutUnprepareHeader Lib "winmm.dll" Alias "waveOutUnprepareHeader" (ByVal hWaveOut As Long, ByVal lpWaveOutHdr As WAVEHDR, ByVal uSize As Long) As Long
Public Const WAVE_MAPPER = -1& Public Const WAVE_FORMAT_PCM = 1
Public Structure WAVEHDR Dim lpData As Int32 Dim dwBufferLength As Int32 Dim dwBytesRecorded As Int32 Dim dwUser As Int32 Dim dwFlags As Int32 Dim dwLoops As Int32 Dim reserved As Int32 Dim lpNext As Int32 End Structure
Public Structure WAVEFORMATEX Dim wFormatTag As Int16 Dim nChannels As Int16 Dim nSamplesPerSec As Int32 Dim nAvgBytesPerSec As Int32 Dim nBlockAlign As Int16 Dim wBitsPerSample As Int16 Dim cbSize As Int16 End Structure
Structure MMTIME Dim wType As Long Dim u As Long End Structure
That should be enough to get ya started. It's a pretty easy API to get, have fun. Hope this helps.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I would like to is there any way I can run the above mentioned files using a contol in VB.NET. This is for the purpose of displaying advertisement that comes in these mentioned format.
|
| Sign In·View Thread·PermaLink | 1.33/5 (2 votes) |
|
|
|
 |
|
|
 |
|
|
 |
|
 |
This class file is extremely efficient...I found this useful for a product to play a sound on a notification....Exactly what I was looking for....something to play a sound...any sound....something that has a small foot-print and add next to nothing on the memory footprint.
Micronic
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
 |
Yes, there are a few ways you can play mp3/wma files.
You can use a 3rd party library. Example: the Bass Sound System or FMod.
You can use the Windows Media Player Component.
Or the method I recommend, is to use the MCI Command Interface, which is supported on Win9x all the way up to the latest Windows XP versions and such. You do not have to really worry about compatibility or worry about Distributing any files with your applications going this route.
I have pre-made librarys that will do what you want and more, and is ready to go. Or you can check out the tutorial at my website that will show you how to use the mciSendString Command Interface yourself to make a full-featured media application.
It is completely up to you. Hope this helps 
Jason
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi, I m using .net 2003. I don’t fine anything like .position with control AxWindowsMediaPlayer. I want to stop playing file at specific time too. I mean one can enter starting and terminating time through edit box and control must repetitively play file in between that time only. If any one has a solution without .position then kindly post the same. Regards, -Parth
-- modified at 13:37 Thursday 22nd June, 2006
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
in code
AxMediaPlayer1.FileName="c:\temp\test.avi"
AxMediaPlayer1.Play
working properly, but when I try to play .wmv
files
AxMediaPlayer1.FileName="c:\temp\test.wmv"
AxMediaPlayer1.Play
i got error in line axmediaplayer1.play
files test.avi and test.wmv exist adn they work properly in any player
Why?
I think that this error is same one as if I dont have file or file is wrong.
"An unhandled exeption of type
System.runtime.interoptservices.COMExeption
occured in axiteropt.mediaplayer.dll
Additional information: Unspecified error"
File test.wmv exist and work in Windows media player when i start his directly
Thanks in advance
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
I understand that the API presented here may offer some additional functionality. But, since folks are wanting to know how to PLAY a *.Wav file in VB.NET, what's wrong with the following code snippet?
My.Computer.Audio.Play("ringingout.wav", AudioPlayMode.Background)
Would that not be the .NET way to do it?
I hope this helps others, that simply want to play a sound.
DBDoctor - Dan.
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
That feature was added to 2.0 version of the .NET Framework.
DotNetFramework 1.0/1.1 does NOT have those capabilities. Only version 2.0 has it.
Jason
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
My application has a module in which we want to be able to give the user an option to add a voice tag to their module. Any idea what classes I could use to do that ? I tried a bunch of the stuff available online but nothing really worked ?
-Parik. http://parik.in
|
| Sign In·View Thread·PermaLink | 1.00/5 (2 votes) |
|
|
|
 |
|
 |
Hi, one of the easier ways to record is to use the MCI Command Interface. It is 'somewhat' flexible and gives you the ability to specify some of the quality settings.
I have a full tutorial on how to Learn to program the mciSendString Command Interface in your applications to be able to perform most media based functionality.
My site link is in my signature at the bottom of this post.
I do plan on releasing a new version of my csMusicLibrary Library for Visual Basic 2005 in the near future. It will have basic recording capabilities already incorporated in the library. The class is almost complete, but I have to finish debugging plus some tweaking here and there.
But you may not want to wait until the new library is released. So I suggest you go check out the tutorial I made.
Hope this helps 
Jason
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I'm pretty new to VB (started in Jan) but I would really like to add this to one of my projects. I copied and pasted the code but I keep getting
PlayWaveFile is not a member of MAD.Sound (MAD is the title of the project)
What am I doing wrong?
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Don't just copy and paste the code from above as it is incomplete. Download the entire class file and add that to your application.
|
| Sign In·View Thread·PermaLink | 1.00/5 (3 votes) |
|
|
|
 |
|
|
 |
|
 |
you can play WAV files in VB.net 2005 (.net framework 2.0)(Express Beta2)
use the my.computer.audio object you can play system sounds and WAVS embeded into your projects resources
Examples My.Computer.Audio.PlaySystemSound (System.Media.SystemSounds.Exclamation) My.Computer.Audio.Play(My.Resources.doorbell, AudioPlayMode.Background)
|
| Sign In·View Thread·PermaLink | 2.50/5 (4 votes) |
|
|
|
 |
|
 |
With .Net Framework 2.0 you could also use:
Dim sound As New Microsoft.VisualBasic.Devices.Audio() sound.PlaySystemSound(SystemSounds.Exclamation)
It is extra code but I thought it was something cool to know. Heh Heh
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |