[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Open Sounds From URL



Hey guys! I figured out how to open sounds from urls! Enjoy!

#! /usr/bin/env python

import urllib2, time
from pygame import mixer
from cStringIO import StringIO

#Read the sound from the url
f = urllib2.urlopen("http://pymike93.googlepages.com/shoot.wav").read()

#Convert to a file
snd = StringIO(f)

#Convert to a sound!
mixer.init()
sound = mixer.Sound(snd)
sound.play()

#Pause while you listen to a sound loaded from an online database!
time.sleep(1)


--
- PyMike