Simple background sound effect playback

Jacob Kruger jacob at blindza.co.za
Sat Dec 20 09:02:51 EST 2014


Ok, thanks - the following seemed to work perfectly:

#start code
import pygame, time
pygame.mixer.init(frequency=22050, size=-16, channels=2, buffer=4096)
song = pygame.mixer.Sound("bird.ogg")
channel = pygame.mixer.Sound.play(song)
channel.set_volume(0, 1)
time.sleep(1)
channel.set_volume(1, 0)
channel = pygame.mixer.Sound.play(song)
time.sleep(1)
#end code

Will now just have to double-check/test compilation of something including something like this, using something like cx_freeze, etc., but, thanks again.

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
...Roger Wilco wants to welcome you, to the space janitor's closet...
---original message---
<catalinfest at gmail.com> wrote in message news:e5f211da-d16a-4351-8094-55ba9d2d35a8 at googlegroups.com...
> See this :
> 
>>>> pygame.mixer.init(frequency=22050, size=-16, channels=2, buffer=4096)
>>>> song = pygame.mixer.Sound("bird.ogg")
>>>> pygame.mixer.Sound.play(song)
> and then use the 
>>>> channel.set_volume(0, 1)
>>>> time.sleep(1)
> 
> 
> On Wednesday, December 17, 2014 10:02:30 PM UTC+2, Jacob Kruger wrote:
>> 
>> 
>> Ok, trying simple code from a pygame tutorial 
>> snippet - nothing happens - just silent, but with no errors being 
>> returned:
>> # import the pygame module
>> import  pygame
>> # start pygame
>> pygame.init()
>> # load a sound file into memory
>> sound = pygame.mixer.Sound("bird.ogg")
>> channel = sound.play()
> -- 
> https://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20141220/c07e4743/attachment.html>


More information about the Python-list mailing list