windows.winmm: Add binding to play mp3s.

db4
Doug Coleman 2013-04-26 11:06:49 -07:00
parent bb9abd6926
commit 5054b6b3de
3 changed files with 42 additions and 0 deletions

View File

@ -22,4 +22,5 @@ CONSTANT: MAX_UNICODE_PATH 32768
{ "ole32" "ole32.dll" stdcall }
{ "usp10" "usp10.dll" stdcall }
{ "psapi" "psapi.dll" stdcall }
{ "winmm" "winmm.dll" stdcall }
} [ first3 add-library ] each

View File

@ -0,0 +1 @@
Doug Coleman

View File

@ -0,0 +1,40 @@
! Copyright (C) 2013 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.c-types alien.syntax byte-arrays formatting kernel
math windows.types ;
IN: windows.winmm
LIBRARY: winmm
TYPEDEF: int MCIERROR
FUNCTION: MCIERROR mciSendStringW (
LPCTSTR lpszCommand,
LPTSTR lpszReturnString,
UINT cchReturn,
HANDLE hwndCallback
) ;
ALIAS: mciSendString mciSendStringW
ERROR: mci-error n ;
: check-mci-error ( n -- )
[ mci-error ] unless-zero ;
: open-command ( path -- )
"open \"%s\" type mpegvideo alias MediaFile" sprintf f 0 f
mciSendString check-mci-error ;
: play-command ( -- )
"play MediaFile" f 0 f mciSendString check-mci-error ;
: pause-command ( -- )
"pause MediaFile" f 0 f mciSendString check-mci-error ;
: status-command ( -- bytes )
"status MediaFile mode" 128 <byte-array> [ 0 f mciSendString check-mci-error ] keep ;
: close-command ( -- )
"close MediaFile" f 0 f mciSendString check-mci-error ;