Hi all,
i'm currently writing a program where i want to play a wav file from within the program.
I can solve it by calling "C:\program files\windows media player\wmplayer.exe" test.wav
but then i have no control over the file anymore.
I'm sure there should be an easy way to do this, but all i can find are code for C# and VB and all functions used there aren't windows API's which i can easily invoke from within masm.
Any idea?
Thanks in advance!
Regards,
Mark
Have a look at Waveform Functions (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_waveform_functions.asp). I have used sndPlaySound in the past.
HTH,
Darrel
Wonderful!!!
So there ARE Api's for it... Thanks, that's all i needed to know for now ;-))
You can also use MCI - which basically gives you a wmplayer 'window' that you have control over - so you can play wav, mp3, etc; play, stop, skip, ...
Quote from: Tedd on October 11, 2005, 11:15:09 AM
You can also use MCI - which basically gives you a wmplayer 'window' that you have control over - so you can play wav, mp3, etc; play, stop, skip, ...
What MCI function to do fast forward dan backward?
I don't think there are real fast-forward and fast-reverse, but so you can use seek.
Thanks guys, the API's were all i needed, it works like a charm...
Hello,
The answer is in the SDK,i translate it for masm
SonWav PROTO :DWORD
;déclaring the ressource in .RC, 530 WAVE DISCARDABLE "name.wav"
;include winmm.lib et winmm.inc
;call functio like that, invoke SonWav,530
;les macros SADD et FUNC font parties de MASM32
;################################################################
SonWav PROC IDwave:DWORD
; Local retour:DWORD
; Local hResInfo:DWORD,hRes,lpRes,bRtn
mov retour,0
; Trouver la ressource WAVE défini ainsi dans le .rc
mov hResInfo,FUNC(FindResource,hInstance, IDwave,SADD("WAVE"))
; .if eax == 0
; wavechec:
; invoke MessageBox,NULL,SADD("son wavechec"),SADD("ECHEC"),MB_OK
; jmp FindeSonWav
; .endif
;charger la ressource
mov hRes,FUNC(LoadResource,hInstance, hResInfo)
.if hRes == NULL
; jmp wavechec
.endif
; verrouiller la ressource et la jouer
mov lpRes,FUNC(LockResource,hRes)
.if lpRes != NULL
mov bRtn,FUNC(sndPlaySound,lpRes, SND_MEMORY + SND_SYNC + SND_NODEFAULT)
;invoke UnlockResource,hRes ;obsolete pas necessaire en 32 bits
; mov retour,eax
.endif
;libérer la resource et passer la valeur de retour
invoke FreeResource,hRes
FindeSonWav:
mov eax,retour
ret
SonWav endp
That code indeed is nice if you want to use a wav packed as resource but since i want the user to choose the wav file himself i've made an openfile button so he can select it.