gamelib.py
def _playsoundWin(sound: str) -> None:
        "Plays a sound for Windows."

        from ctypes import c_buffer, windll
        from random import random
        from sys import getfilesystemencoding

        def winCommand(*command: Tuple[str, ...]):
            "Executes a Windows Command."

            buf = c_buffer(255)
            command = ' '.join(command).encode(getfilesystemencoding())
            errorCode = int(windll.winmm.mciSendStringA(command, buf, 254, 0))
            if errorCode:
                errorBuffer = c_buffer(255)
                windll.winmm.mciGetErrorStringA(errorCode, errorBuffer, 254)
                exceptionMessage = ("\n    Error " + str(errorCode) + " for command:"
                                    "\n        " + command.decode() +
                                    "\n    " + errorBuffer.value.decode(getfilesystemencoding(), "ignore"))
                raise PlaysoundException(exceptionMessage)
            return buf.value

        alias = "playsound_" + str(random())
        winCommand("open \"" + sound + "\" alias", alias)
        winCommand("set", alias, "time format milliseconds")
        durationInMS = winCommand("status", alias, "length")
        winCommand("play", alias, "from 0 to", durationInMS.decode())
Plays a sound for Windows.
Plays a sound for Windows.
Plays a sound for Windows .
def _playsoundWin(sound: str) -> None:
        from ctypes import c_buffer, windll
        from random import random
        from sys import getfilesystemencoding
        def winCommand(*command: Tuple[str, ...]):
            buf = c_buffer(255)
            command = ' '.join(command).encode(getfilesystemencoding())
            errorCode = int(windll.winmm.mciSendStringA(command, buf, 254, 0))
            if errorCode:
                errorBuffer = c_buffer(255)
                windll.winmm.mciGetErrorStringA(errorCode, errorBuffer, 254)
                exceptionMessage = ("\n    Error " + str(errorCode) + " for command:"
                                    "\n        " + command.decode() +
                                    "\n    " + errorBuffer.value.decode(getfilesystemencoding(), "ignore"))
                raise PlaysoundException(exceptionMessage)
            return buf.value
        alias = "playsound_" + str(random())
        winCommand("open \"" + sound + "\" alias", alias)
        winCommand("set", alias, "time format milliseconds")
        durationInMS = winCommand("status", alias, "length")
        winCommand("play", alias, "from 0 to", durationInMS.decode())
def _playsoundWin ( sound : str ) -> None : from ctypes import c_buffer , windll from random import random from sys import getfilesystemencoding def winCommand ( * command : Tuple [ str , ... ] ) : "Executes a Windows Command." buf = c_buffer ( 255 ) command = ' ' . join ( command ) . encode ( getfilesystemencoding ( ) ) errorCode = int ( windll . winmm . mciSendStringA ( command , buf , 254 , 0 ) ) if errorCode : errorBuffer = c_buffer ( 255 ) windll . winmm . mciGetErrorStringA ( errorCode , errorBuffer , 254 ) exceptionMessage = ( "\n    Error " + str ( errorCode ) + " for command:" "\n        " + command . decode ( ) + "\n    " + errorBuffer . value . decode ( getfilesystemencoding ( ) , "ignore" ) ) raise PlaysoundException ( exceptionMessage ) return buf . value alias = "playsound_" + str ( random ( ) ) winCommand ( "open \"" + sound + "\" alias" , alias ) winCommand ( "set" , alias , "time format milliseconds" ) durationInMS = winCommand ( "status" , alias , "length" ) winCommand ( "play" , alias , "from 0 to" , durationInMS . decode ( ) )
Plays a sound for Windows.
Plays a sound for Windows .
"Plays a sound for Windows." "Executes a Windows Command."
sound
str