pyinstaller
Arlie
arlie.c at gmail.com
Sun Jun 21 21:07:47 EDT 2009
Imported files in myprog.py:
import MySQLdb
import os # works on Windows or Linux, also Vista
import os.path
import time
import mp3
~~~~~~~
Content of mp3.py:
# -*- coding: utf-8 -*-
#Michel Claveau
import time
from ctypes import windll, c_buffer
class mci:
def __init__(self):
self.w32mci = windll.winmm.mciSendStringA
self.w32mcierror = windll.winmm.mciGetErrorStringA
def send(self,commande):
buffer = c_buffer(255)
errorcode = self.w32mci(str(commande),buffer,254,0)
if errorcode:
return errorcode, self.get_error(errorcode)
else:
return errorcode,buffer.value
def get_error(self,error):
error = int(error)
buffer = c_buffer(255)
self.w32mcierror(error,buffer,254)
return buffer.value
def directsend(self, txt):
(err,buf)=self.send(txt)
if err != 0:
print'Error',str(err),'sur',txt,':',buf
return (err,buf)
###################################################################
def play(mp3file):
xmci=mci()
xmci.directsend('open "' + mp3file + '" alias toto')
xmci.directsend('set toto time format milliseconds')
err,buf=xmci.directsend('status toto length ')
#print 'Duree du fichier : ',buf,' millisecondes'
soundlength = int(buf) / 1000
err,buf=xmci.directsend('play toto from 0 to '+str(buf))
#time.sleep(int(buf)/1000)
time.sleep(soundlength + 1)
xmci.directsend('close toto')
More information about the Python-list
mailing list