Det er fuld ud muligt... Hvis du spiller cd´er eller mp3´er osv. Det kan sagtens kører, du skal nok bare starte lyden først, derefter starte spillet, der er bare en bagside, du mister cpu kraft ved at hører msuik, da den skal køre begge dele. Men hvis du her en god cpu så kan du sagtens!!! MVH KinGuru
Option Explicit Private Declare Function mciSendString Lib \"winmm.dll\" Alias _ \"mciSendStringA\" (ByVal lpstrCommand As String, _ ByVal lpstrReturnString As String, _ ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Private Sub Command2_Click() Dim i As Long, RS As String, cb As Long RS = Space$(128) i = mciSendString(\"stop sound\", RS, 128, cb) i = mciSendString(\"close sound\", RS, 128, cb) End Sub
Private Sub Command1_Click() Command2_Click Dim i As Long, RS As String, cb As Long, W$ RS = Space$(128) W$ = \"c:\\windows\\media\\done.wav\" i = mciSendString(\"open waveaudio!\" & W$ & \" alias sound\", RS, 128, cb) If i Then MsgBox \"Error! Probably file not found. _ Modify the code to point to a .WAV file on your system.\" i = mciSendString(\"play sound\", RS, 128, cb) End Sub
Du skal som du kan se bruge to knapper. w$ er stien på den fil du gerne vil spille (Husk dette er kun WAV!!!) command1 bruges til at stoppe og lukke sangen mens command2 bruges til at afspille den!
\'The following will open the sequencer with the C:\\WIN31\\CANYON.MID \'file. Canyon is the device_id.
ret = mciSendString(\"open c:\\windows\\CANYON.MID _ type sequencer alias canyon\", 0&, 0, 0)
\'The wait tells the MCI command to complete before returning control \'to the application.
ret = mciSendString(\"play canyon wait\", 0&, 0, 0)
\'Close CANYON.MID file and sequencer device
ret = mciSendString(\"close canyon\", 0&, 0, 0)
End Sub
Og i General delarations:
#If Win32 Then Private 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
#ElseIf Win16 Then
Private Declare Function mciSendString Lib \"mmsystem\" (ByVal _ lpstrCommand As String, ByVal lpstrReturnStr As Any, ByVal _ wReturnLen As Integer, ByVal hCallBack As Integer) As Long
I øvrigt skal du ikke bruge de gamle lyd afspilnings komponenter i VB, de er fra Win9x tiden.
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.