[Tutor] read sound file via url
nicolas maleve
nmaleve at all2all.org
Thu Apr 15 20:06:21 EDT 2004
hello,
I make my first steps with the snack library.
I would like to make a python script to read an ogg file over the net.
At the moment the only solution I could manage to get working is to save the
file on disk and then read it.
For larger sound file, I would prefer to read them directly via a url.
Can anyone put me in the right direction?
here follows my script with the locally saved version...
#! /usr/bin/env python
#
# Usage: oggplay.py http://www.myserver.com/file.ogg
#
# Note: this script will also play audio files in any other format supported
# by tkSnack
import urllib
import sys
from Tkinter import *
from tkSnack import *
initializeSnack(Tkinter.Tk())
# Load the Ogg/Vorbis format package
Tk().tk.eval('package require snackogg')
if sys.argv[1:]:
host=sys.argv[1]
file=urllib.urlopen(host)
test=file.info()
print test
print "reading\n"
snd_net = file.read()
f=open("test.ogg","wb")
print "opening file for writing"
f.write(snd_net)
print "writing\n"
f.close()
print "closed\n"
print "now trying to play\n"
snd=Sound(file="test.ogg")
snd.play(blocking=1)
print "does it exit now?"
else:
print "Usage: oggplay.py http://www.myserver.com/file.ogg"
--
*
*
*
*
*
*
*
*
*
C O N S T A N T
V Z W
More information about the Tutor
mailing list