Skip to content

Instantly share code, notes, and snippets.

@wkta
Created March 22, 2014 11:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wkta/9705505 to your computer and use it in GitHub Desktop.
Save wkta/9705505 to your computer and use it in GitHub Desktop.
#MonthOfCode day 13 - sound
import pygame
from time import sleep
#replace this by some cool sound effect & music !
SFX = 'alrighty.wav'
MUSIC = '4sequence.mp3'
# init pygame ; load n play a sound effect
pygame.init()
soundObj = pygame.mixer.Sound('alrighty.wav')
soundObj.play()
# load n play some background music
pygame.mixer.music.load('4sequence.mp3')
pygame.mixer.music.play(-1, 0.0)
# replace the sleep by whatever your game needs to do
sleep(16)
# stopping sound before exit
pygame.mixer.music.stop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment