""" August 9, 2011 @author: Janne Parkkila @email: japskua@gmail.com @summmary: This file contains code for playing music/sounds on N900 with Python programming language. This implementation uses pygame instead of gstreamer """ import pygame class Player(object): def __init__(self): """ @summary: The Constructor class """ pygame.mixer.quit() pygame.mixer.init() pygame.init() def Play(self, sound): """ @summary: This function is used to play the given sound @param sound: The sound to be played @type sound: pygame sound object """ sound.play() def Load(self, filename): """ @summary: This function loads the given filename into a pygame readable sound object @param filename: The path to the file to be loaded @type filename: String @return: Loaded pygame music object @rtype: pygame Sound """ return pygame.mixer.Sound(filename) if __name__ == "__main__": # Initialize the player player = Player() # Load the soundfile with the player sound = player.Load("button-4.wav") # Play the file player.Play(sound)