Play AVI/WAVE Files from Memory

Just starting out? Need help? Post your questions and find answers here.
Tomio
Enthusiast
Enthusiast
Posts: 291
Joined: Sun Apr 27, 2003 4:54 pm
Location: Germany

Play AVI/WAVE Files from Memory

Post by Tomio »

hello,

I had a posting recently "open wav with MCI" and, in a way the following is a continuation:

The API "playsound" mentioned there, does not make me happy. It's to restricted.

But I found a hint in Microsoft Knowledge Base (Article - 155360) that would fit my needs perhaps perfectly, as I would have to modify my program only slightly:

--> "HOWTO: Use MCI to Play AVI/WAVE Files from Memory"

The problem is the use of mmioInstallIOProc.

Ok, here my question: does someone has an example how to translate this in PB?

Would be a great help for me, because my tool is tied up with MCI.

../tomio
Tomio
Enthusiast
Enthusiast
Posts: 291
Joined: Sun Apr 27, 2003 4:54 pm
Location: Germany

Re: Play AVI/WAVE Files from Memory

Post by Tomio »

Ok, no answer so far, but...
I was able to convert the "HOWTO: Use MCI to Play AVI/WAVE Files from Memory" Article myself.
And I'm really enthusiastic about the new possibilities I see for my tool.
The reason is: I like mci commands to work with wav-files.
They are very handy and, from my point of view, give you everything you need to control your wav-file.
And you don't need any additional lib.
But only with the simple workaround mentioned here, it is possible to work with files already located in memory.
That's what I was missing so grievously.
Perhaps some of you think the same and that's why I post my conversion here.
Technically it's not difficult. You have to know, that's all. And finally, here is the code:
;
;Don't forget, the wav is already loaded in memory (ReadData()).
Global *mm_Data, mm_size.l, mm_4.l, mm_opn
Declare P_mm_IO(*lpM.MMIOINFO,mesg.l,param1.l,param2.l)

;*mm_Data is pointer to the memory location of the loaded wav-file
;mm_size is the file size
mm_4.l=mmioStringToFOURCC_("ABC",#MMIO_TOUPPER)
;could be anything other than "ABC", but not more than 3.
mm_opn=0
;Now the private IOroutine is being loaded:
mmioInstallIOProc_(mm_4,@P_mm_IO(),#MMIO_INSTALLPROC)
;Now an almost normal mci open command: but note the 'filename':
;..it's the extension "ABC+" which makes mci to use your private
;..routine P_mm_IO() for IO with wav at memory address *mm_Data:
uu.l=mciSendString_("open x.ABC+ type waveaudio alias test",0,0,0)
;from here on, you do mci commands (play [from], pause, status,..) as usual!
;...
;...
;when finished, close this way:
mciSendString_("close test",0,0,0)
mmioInstallIOProc_(mm_4,#NULL,#MMIO_REMOVEPROC)
FreeMemory(0)

;and here the routine:
Procedure P_mm_IO(*lpM.MMIOINFO,mesg.l,lparam1.l,lparam2.l)
Select mesg
Case #MMIOM_OPEN
If mm_opn=1: ProcedureReturn 0: EndIf
mm_opn=1
*lpM\lDiskOffset = 0:ProcedureReturn 0
Case #MMIOM_CLOSE: ProcedureReturn 0
Case #MMIOM_READ
CopyMemory(*mm_Data+*lpM\lDiskOffset,lParam1, lParam2)
*lpM\lDiskOffset + lParam2;
ProcedureReturn lParam2
Case #MMIOM_SEEK
Select lParam2
Case #SEEK_SET
*lpM\lDiskOffset = lParam1
Case #SEEK_CUR
*lpM\lDiskOffset + lParam1
Case #SEEK_END
*lpM\lDiskOffset = fileSize - 1 - lParam1;
EndSelect
ProcedureReturn *lpM\lDiskOffset;
Default
ProcedureReturn -1
EndSelect
ProcedureReturn
EndProcedure


;../tomio
Post Reply