how to play sound in vb
(when i press key the music plays
It was so much easier in the good old DOS Days... You had direct control of the hardware and didn't have to fight with the Hardware Abstraction Layer...
In <Project> <Components> you can add the "Windows Media Player" Control and this will give you control of MP3; WMA; and .WAV (Maybe a few others).
This is the code from a desktop Alarm Clock I put together
Private Sub Do_Alarm(aFile As String, aPrompt As String) If Not Muted Then wmp.settings.volume = 100 wmp.URL = aFile wmp.Controls.play End If Call Set_Prompt If Not Hold_Off Then Prompt.Show Prompt.Prompt.Caption = " " Prompt.Prompt.Caption = aPrompt End Sub
You can also use the Media Control Interface by Declaring it in a Module
Declare Function mciSendString Lib "winmm.dll" Alias _ "mciSendStringA" (ByVal lpstrCommand As String, ByVal _ lpstrReturnString As Any, ByVal uReturnLength As Long, ByVal _ hwndCallback As Long) As Long
However, the MCI interface will not work on some "Locked Down" Computers...
Once you start the sound the following code should stop it
Private Sub mmnuStop_Click() Clock.wmp.Close End Sub
DoAlarm is called as follows
Do_Alarm Alarms.fgAlarms.TextMatrix(n, 6), Alarms.fgAlarms.TextMatrix(n, 7)
Where field 6 is the File Path to be Played and Field 7 is the User Prompt to be Displayed.
There is a delay in playing using the WMP control.
If the system is not locked down then the MCI control is a bit faster if memory serves me well. But, it is also much more complex to use...
I may have the old code lying around some where...
i am trying to create a library management system which is supposed to be used to store/keep infp for the library and the library members( book title, author, name and picture for borrower and other stuffs). The app has 6 buttons, delete, save, add,previsous,next, and upload( for upload ...
Im trying to bind my custom vertical scrollbar to datagridview is this possible.. Please help Thnak you..
I have two tables, I will call them first-half and second-half (of the year)
Table: first id jan feb mar apr ----------------------- 2 80 90 70 60 3 50 40 60 30 Table: second id jan feb mar apr ----------------------- 2 50 70 60 90 3 80 60 50 ...