Permalink
Browse files

windows.winmm: Add binding to play mp3s.

  • Loading branch information...
erg committed Apr 26, 2013
1 parent 065338a commit 20faf95242fcafa85e7b62b85339c3d8f3687dec
Showing with 42 additions and 0 deletions.
  1. +1 −0 basis/windows/windows.factor
  2. +1 −0 basis/windows/winmm/authors.txt
  3. +40 −0 basis/windows/winmm/winmm.factor
@@ -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
@@ -0,0 +1 @@
Doug Coleman
@@ -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 ;

0 comments on commit 20faf95

Please sign in to comment.