I'm working with the Audio Module as part of a class assignment and I'm not very familiar with python.
I wrote a simple class that basically wraps the Audio Module functions just so I could test my knowledge of whats happening, but I've run into problems.
Here's my code:
Code:from audio import * class AudioTool: def __init__(self, file): self = Sound.open(file) def playSound(self): self.play(2, 10) def stopSound(self): self.stop() if __name__ == '__main__': test = 'Z:\mail.wav' sound = AudioTool(test) sound.playSound()
And Im getting an error saying that self has no 'play' attribute. I thought that setting self = Sound.open(file) would make self equivalent to a Sound Object, but apparently thats not the case.
I also tried:
Code:from audio import * class AudioTool: def __init__(self): pass def playSound(self, file): music = Sound.open(file) music.play(2, 10) def stopSound(self): Sound.stop() if __name__ == '__main__': test = 'Z:\mail.wav' sound = AudioTool().playSound(test)
And although that gave me no errors, I was not able to get the file to playback.
Can anyone show me where I've gone wrong with either of the above scenarios?
Thanks.



