/
SOUNDREC.PY
137 lines (104 loc) · 4.11 KB
/
SOUNDREC.PY
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# copyright 2008 OsaMa -ITQPDA
import appuifw, audio, os,e32
import db,time
from graphics import *
import powlite_fm as fm
def ar(x):return x.decode('utf8')
settings = db.set(save=1)
#========================
# app info
appuifw.app.screen='normal'
appuifw.app.body = b = appuifw.Text()
b.style = appuifw.STYLE_BOLD
appuifw.app.body.color=0x0000ff
b.add(ar(' ITQPDA SoundREC. v1.0\n===========================\n Author: Osamadj.\n For\n http://www.i-tich.net\n English by:\n ~: ITQPDA Team :~\n For\n www.ipmart-forum.com \n'))
#========================
osamadir=u'E:\\itqpda\\'
try:
if not os.path.exists(osamadir):
os.makedirs(osamadir)
else:
pass
except:
appuifw.note(u"Couldn't create the directory!", "error")
def std():
date = time.strftime('_%d%m%Y_%H_%M_%S')
appuifw.note(ar('you are Recording in ( ')+settings.TYPE+u" ) Format","info")
filename =u'E:\\itqpda\\rec'+date+u'.'+settings.TYPE
# create your icons for the listbox content
icon1 = appuifw.Icon(u"e:\\system\\apps\\itqpda-s_r\\osama.mbm", 38, 39)
icon2 = appuifw.Icon(u"e:\\system\\apps\\itqpda-s_r\\osama.mbm", 04, 05)
icon3 = appuifw.Icon(u"e:\\system\\apps\\itqpda-s_r\\osama.mbm", 10, 11)
icon5 = appuifw.Icon(u"e:\\system\\apps\\itqpda-s_r\\osama.mbm", 40, 41)
icon6 = appuifw.Icon(u"e:\\system\\apps\\itqpda-s_r\\osama.mbm", 10, 11)
icon4 = appuifw.Icon(u"e:\\system\\apps\\itqpda-s_r\\osama.mbm",12,13)
# create your content list of your listbox including the icons to be used for each entry
entries = [(ar(' Record'), icon1),(ar(' Play >'), icon5),(ar(' Stop []'), icon3),
(ar(' Open Song'), icon4),(ar(' Record Type'), icon2)]
def set_type():
tp = appuifw.popup_menu([u'1- amr', u'2- wav'], ar('Type of recorded Sound'))
if tp==0:
settings.TYPE = u'amr'
std()
elif tp==1:
settings.TYPE = u'wav'
std()
def rec():
global S
S=audio.Sound.open(filename)
S.record()
appuifw.query(ar('Recording.......\nPress OK to stop recording'), "query")
S.stop()
def play():
global S
try:
S=audio.Sound.open(filename)
S.play()
appuifw.note(ar('Playing'),"info")
std()
except:
appuifw.note(ar('Record first a sound!'),"error")
def stop():
global S
S.stop()
S.close()
appuifw.note(ar('Stopped'),"info")
std()
def open():
appuifw.note(ar('Please Select a Sound '))
filem = fm.manager()
spa = filem.AskUser(path=u'e:\\sounds', find='file',ext=[(u'.amr'),(u'.wav'),(u'.mp3')])
if spa:
if spa[-1] == '\\':
spa=spa[:-1]
if spa[-1] == '\\':
spa=spa[:-1]
filename = spa
global S
try:
S=audio.Sound.open(spa)
S.play()
appuifw.note(ar('Playing'),"info")
except:
appuifw.note(ar('Select a Sound!'),"error")
# create the listbox callback handler
def fun():
index = lb.current()
if index ==0:rec()
elif index ==1:play()
elif index ==2:stop()
elif index ==3:open()
elif index ==4:set_type()
lb = appuifw.Listbox(entries,fun)
appuifw.app.body = lb
def opgal():
e32.start_exe(u"z:\\system\\programs\\apprun.exe",ar("\"Z:\\System\\Apps\\MediaGallery\\MediaGallery.app\" "))
def about():
appuifw.note(ar('Programed By\n .: OsaMa :.'),"info")
appuifw.note(ar('Keep visit\n .: www.i-tich.net :.'),"info")
def exit():
app_lock.signal()
appuifw.app.menu=[(ar('Media Center'),std),(ar('Open Gallery'),opgal),(ar('About'),about),(ar('Exit'),exit)]
appuifw.app.exit_key_handler = exit
app_lock = e32.Ao_lock()
app_lock.wait()