[Python] R: suoni
renzo
renzocavallini a alice.it
Sab 12 Apr 2008 18:57:22 CEST
Ho usato questo programmino trovato su internet
######################################################################
import threading
import os
(
GSTPLAY,
WINPLAY,
NOENGINE
) = range(3)
try:
import gst
import gobject
ENGINE = GSTPLAY
except ImportError:
try:
import winsound
ENGINE = WINPLAY
except ImportError:
ENGINE = NOENGINE
class __GstPlayThread(threading.Thread):
def __init__(self, ply):
self.ply = ply
threading.Thread.__init__(self)
def run(self):
self.ply.set_state(gst.STATE_PLAYING)
def bus_event(bus, message):
t = message.type
if t == gst.MESSAGE_EOS:
self.ply.set_state(gst.STATE_NULL)
return True
self.ply.get_bus().add_watch(bus_event)
def __gstplay(filename):
cwd = os.getcwd()
location = os.path.join(cwd, filename)
ply = gst.element_factory_make("playbin", "player")
ply.set_property("uri", "file://" + location)
pt = __GstPlayThread(ply)
pt.start()
def __winplay(filename):
cwd = os.getcwd()
location = os.path.join(cwd, filename)
import thread
def wplay():
winsound.PlaySound(location, winsound.SND_FILENAME)
thread.start_new_thread(wplay, ())
if ENGINE == GSTPLAY:
play = __gstplay
pass
elif ENGINE == WINPLAY:
play = __winplay
else:
def play(filename):
pass
############################################################################
###################
-----Messaggio originale-----
Da: python-bounces a lists.python.it [mailto:python-bounces a lists.python.it]
Per conto di Massimiliano Giovine
Inviato: giovedì 10 aprile 2008 23.38
A: Discussioni generali sul linguaggio Python
Oggetto: Re: [Python] suoni
Usa la libreria SDL_mixer, è molto comoda per caricare file audio...
2008/4/10, enrico franchi <enrico.franchi a gmail.com>:
> On Fri, Apr 11, 2008 at 6:54 PM, renzo <renzocavallini a alice.it> wrote:
>
> > Ho la necessità di far suonare un file wav sotto linux
>
>
> SDL dovrebbe fare al caso tuo.
>
>
> > Con windows ci sono riuscito
>
>
> Che libreria hai usato?
>
>
>
> --
> VENITE TUTTI A PYCON 2!
> _______________________________________________
> Python mailing list
> Python a lists.python.it
> http://lists.python.it/mailman/listinfo/python
>
--
-Massimiliano Giovine
Aksel Peter Jørgensen dice: "Why make things difficult, when it is
possible to make them cryptic and totally illogic, with just a little
bit more effort?"
Blog: http://opentalking.blogspot.com
Il vero programmatore:
http://www.arcetri.astro.it/~comore/true_programmer.txt
_______________________________________________
Python mailing list
Python a lists.python.it
http://lists.python.it/mailman/listinfo/python
Maggiori informazioni sulla lista
Python