×
Namespaces

Variants
Actions
Revision as of 11:07, 16 September 2009 by james1980 (Talk | contribs)

Archived:How to record a call using PySymbian

From Nokia Developer Wiki
Jump to: navigation, search
{{{width}}}

The below code is used to record a call using Python.


import appuifw
import e32
from key_codes import *
import audio
 
s = audio.Sound.open('C:\\data\\h.amr')
 
class Keyboard(object):
def __init__(self,onevent=lambda:None):
self._keyboard_state={}
self._downs={}
self._onevent=onevent
def handle_event(self,event):
if event['type'] == appuifw.EEventKeyDown:
code=event['scancode']
if not self.is_down(code):
self._downs[code]=self._downs.get(code,0)+1
self._keyboard_state[code]=1
elif event['type'] == appuifw.EEventKeyUp:
self._keyboard_state[event['scancode']]=0
self._onevent()
def is_down(self,scancode):
return self._keyboard_state.get(scancode,0)
def pressed(self,scancode):
if self._downs.get(scancode,0):
self._downs[scancode]-=1
return True
return False
 
keyboard=Keyboard()
 
def quit():
global running, s
running=0
s.close()
appuifw.app.set_exit()
 
running=1
 
appuifw.app.screen='normal'
 
canvas=appuifw.Canvas(event_callback=keyboard.handle_event, redraw_callback=None)
appuifw.app.body=canvas
 
appuifw.app.exit_key_handler=quit
 
while running:
 
if keyboard.pressed(EScancode2):
s.play()
appuifw.note(u"Playing", "info") #Start Playing
 
 
if keyboard.pressed(EScancode3):
s.stop() # Stop recording
appuifw.note(u"Stopped", "info") #Stopped
 
 
if keyboard.pressed(EScancode1):
appuifw.note(u"Recording", "info")
s.record() # Start recording
 
e32.ao_yield()
94 page views in the last 30 days.
×