Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

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

Archived:How to record a call using PySymbian

From 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()
90 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×