![]() ![]() If you are looking for more advanced functions, you can try mp3play. # like winsound.PlaySound("Wet Hands.wav", winsound.SND_FILENAME | winsound.SND_ASYNC) # add winsound.SND_ASYNC flag if you want to wait for it. ![]() Winsound.PlaySound("Wet Hands.wav", winsound.SND_FILENAME) Not recommended, too few functions import winsound If you are a Windows user,the easiest way is to use winsound.You don't even need to install it. Query the status of the mixer continuously in a loop: import pygame (int(my_sound.get_length() * 1000))Īlternatively you can use _busy to test if a sound is being mixed. (The argument to () is in milliseconds) import pygame Use get_length() to get the length of the sound in seconds and wait for the sound to finish: Finally, you have to wait for the file to play. If you want to play a single wav file, you have to initialize the module and create a () object from the file. The mixer system only supports a single music stream at once. The difference between the music playback and regular Sound playback is that the music is streamed, and never actually loaded all at once. The difference is explained in the documentation: ![]() This module contains classes for loading Sound objects and controlling playback. PyGame has 2 different modules for playing sound and music, the pygame.mixer module and the module. Raise RIFFFormatException('Size of format chunk is incorrect.') Return media.load(path, streaming=streaming)įile "/usr/lib/python2.7/site-packages/pyglet/media/_init_.py", line 1386, in loadįile "/usr/lib/python2.7/site-packages/pyglet/media/riff.py", line 194, in _init_įile "/usr/lib/python2.7/site-packages/pyglet/media/riff.py", line 174, in get_format_chunkįile "/usr/lib/python2.7/site-packages/pyglet/media/riff.py", line 110, in get_chunksĬhunk = cls(self.file, name, length, offset)įile "/usr/lib/python2.7/site-packages/pyglet/media/riff.py", line 155, in _init_ Music = ('mysound.wav')įile "/usr/lib/python2.7/site-packages/pyglet/resource.py", line 587, in media (nc,sw,fr,nf,comptype, compname) = s.getparams( )Īnd when I tried pyglet It give me this error: import pyglet I read this link solutions and can't solve my problem with playing wave file!įor this solution I dont know what should I import? s = Sound()Īnd for this solution /dev/dsp dosen't exist in new version of linux : from wave import open as waveOpen I tried pygame for playing wav file like this: import pygameīut It change the voice and I don't know why! ![]()
0 Comments
Leave a Reply. |