News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Making a simple WAV player

Started by NoCforMe, January 09, 2012, 12:45:57 AM

Previous topic - Next topic

jj2007

Quote from: dedndave on January 15, 2012, 01:29:59 AM
little secret - that also works for VOB files   :P
although - i didn't have any luck with that player - lol

You mean the one I posted? I just tried my luck with Hutch's suggestion but no luck - even renaming to *.mpg just gave a message "damaged file". It opens fine in other players, though, meaning the codecs are there but mci is not able to find them.
For my own private *.avi files instead, renaming to *.mpg helps. If I use them as *.avi, there is a message "video not available", sound works (!), and the mouse is almost blocked.
The whole video business is very, very messy on Windows. I remember that frequently Windows doesn't know about its own formats. Greetings to Redmond :wink

dedndave

i tried a variety of file types - mp4, m4v, flv, and so on - all of which i have codecs for
many of them would not play with your player
by renaming them to mpg, they did play
it did not work for vob's - although, i have had success with that when i did not have a full set of codecs

Bill Cravener

Dave I have a copy of Richard Hammond's BBC documentry of Evil Knievel in VOB format (last he ever gave) its an hour long and it plays perfectly on my Win 7 machine from that simple media player example of mine. I'm quite certain using the MPEGVideo type you can play most any media file if the correct codec is installed on a machine even VOB's. 
My MASM32 Examples.

"Prejudice does not arise from low intelligence it arises from conservative ideals to which people of low intelligence are drawn." ~ Isaidthat

dedndave

yah - VOB files are containers for MPEG video information   :P

Bill Cravener

Dave,

Well to be honest about it I'm not all that savvy about all that media shit, I get an idea for an example I want to create and I start digging into Microsoft's SDK. That's how I derive every example I've created over all these years and at the same time having one hell of a lot of fun doing so. :bg
My MASM32 Examples.

"Prejudice does not arise from low intelligence it arises from conservative ideals to which people of low intelligence are drawn." ~ Isaidthat

dedndave

i hear ya, Bill
i am a novice, too - lol
i do have some interest - i'd like to learn more about it
for now, i am just trying to learn my way around the API   :P

bomz


Quote.386

.model flat, stdcall
option casemap :none

        include \masm32\include\windows.inc
        include \masm32\include\user32.inc
        include \masm32\include\kernel32.inc
        include \masm32\include\comctl32.inc
        include \masm32\include\winmm.inc

        includelib \masm32\lib\user32.lib
        includelib \masm32\lib\kernel32.lib
        includelib \masm32\lib\comctl32.lib
        includelib \masm32\lib\winmm.lib

HookProc   PROTO :DWORD, :DWORD, :DWORD
HookWndProc   PROTO :DWORD, :DWORD, :DWORD, :DWORD

.data
mestitle   db "Bomz",0
Mp3Device   db "MPEGVideo",0
FileName   db "Seven.Years.in.Tibet.1997.BDRip.720p.mkv",0

.data?
mciOpenParms   MCI_OPEN_PARMS <>
mciPlayParms   MCI_PLAY_PARMS <>
Mp3DeviceID   dd ?
hHook      dd ?
ThreadId   dd ?

.code
start:

   invoke GetCurrentThreadId
   mov ThreadId, eax
   invoke SetWindowsHookEx,WH_CALLWNDPROC,addr HookProc,NULL,ThreadId
   mov hHook, eax

      mov eax,0
      mov mciPlayParms.dwCallback,eax   ; функция которой послать сообщение MM_MCINOTIFY об окончании воспроизведения
      lea eax, Mp3Device
      mov mciOpenParms.lpstrDeviceType,eax
      lea eax,FileName
      mov mciOpenParms.lpstrElementName,eax
      invoke mciSendCommand,0,MCI_OPEN,MCI_OPEN_TYPE or MCI_OPEN_ELEMENT,ADDR mciOpenParms
      ;invoke MessageBox,0,0,ADDR mestitle,MB_ICONASTERISK
      mov eax,mciOpenParms.wDeviceID
      mov Mp3DeviceID,eax
      invoke mciSendCommand,Mp3DeviceID,MCI_PLAY,MCI_NOTIFY,ADDR mciPlayParms
      invoke MessageBox,0,0,ADDR mestitle,0;MB_ICONASTERISK
      invoke mciSendCommand,Mp3DeviceID,MCI_CLOSE,0,0
      invoke ExitProcess,0


HookProc PROC nCode:DWORD,wParam:DWORD,lParam:DWORD

   .if nCode==HC_ACTION
   mov edx, lParam
   assume edx:PTR CWPSTRUCT
      .if [edx].message == WM_INITDIALOG
      invoke SetWindowText, [edx].hwnd, addr Mp3Device
      ;invoke MessageBeep, MB_ICONASTERISK
      invoke UnhookWindowsHookEx,hHook
      .endif
   assume edx:nothing
   .endif

   invoke CallNextHookEx,hHook,nCode,wParam,lParam
   xor eax,eax
   ret

HookProc endp

end start