Taking a Photo:
#Copyright (c) 2008 Pankaj Nathani
#Setting the volume and position and getting duration
import audio, appuifw
def stop():
global s
s.stop()
s.close()
s=audio.Sound.open("C:\\s.mp3")
#Show the current volume and the maximum volume
appuifw.note(u"Current volume %d" % s.current_volume())
appuifw.note(u"Max volume %d" % s.max_volume())
#Ask the user for new volume
v=appuifw.query(u"New volume", "number")
s.set_volume(v)
appuifw.note(u"The duration of this song is %d seconds" % int(s.duration()/1000000))
s.set_position(3) #3 seconds
appuifw.note(u"%d seconds have been played" % int(s.current_position())) #In this case 3.4 seconds
Recording Video:
#Copyright (c) 2008 Pankaj Nathani
#Recording video
import camera, e32, appuifw
#Define the exit function
app_lock=e32.Ao_lock()
def quit():
camera.stop_finder()
camera.release()
app_lock.signal()
appuifw.app.exit_key_handler=quit
def video_callback(err, current_state):
global c
if(current_state==camera.EPrepareComplete):c=1
else:pass
appuifw.app.body=appuifw.Canvas()
#Define a function for the viewfinder
def v_finder(im):
appuifw.app.body.blit(im)
camera.start_finder(v_finder, size=(240,196))
vid=camera.start_record("C:\\movie.3gp", video_callback) #Start recording the video
#Record for 5 seconds and then stop
e32.ao_sleep(5)
camera.stop_record()
app_lock.wait()
Using the Viewfinder:
#Copyright (c) 2008 Pankaj Nathani
#Using the viewfinder
import camera, e32, appuifw
from graphics import *
#Define the exit function
app_lock=e32.Ao_lock()
def quit():
camera.stop_finder() #Close the viewfinder
camera.release() #Release the camera so other applications may use it
app_lock.signal()
appuifw.app.exit_key_handler=quit
appuifw.app.body=appuifw.Canvas()
#Define a function for the viewfinder
def v_finder(im):
appuifw.app.body.blit(im)
#Start the viewfinder
camera.start_finder(v_finder, size=(240,160))
app_lock.wait()