[Tutor] sound implementation problems

jessica peters howewriter2000 at yahoo.com
Thu Jun 13 19:21:40 CEST 2013


Hi

I'm about 2 yrs into studying Python - started with "Hello World", and I'm working with v 2.5.1 right now.  The past year I've begun trying to write my own interactive fiction.  That works pretty well, but now I'm attempting to put some music into programs (I thought background music would be good), and I'm running into roadblocks.

I've tried several different things for this, and come up with either my text that comes to a halt eventually at an error message (can't read from the files or mixer isn't initialized are the most common ones), or a completely blank screen with no sound.  I've tried both .mp3 files and .wav ones, neither works for this.

Here's the most recent code I've attempted:

import pygame , sys
import random
size=[500,500]
def run(self):
    import pygame.mixer
    pygame.mixer.init(22050, -16, 2, 4096)
    self.sound.seek(0)
    snd = pygame.mixer.Sound(self.sound)
    pygame.mixer.Sound.play("bach-cello-suite-1.wav")
    musicPlaying = True

Any ideas would  be appreciated.  Thanks.
 
my website: http://jahowe.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130613/fa62155e/attachment.html>


More information about the Tutor mailing list