| ID | Creation date | July 29, 2008 | |
| Platform | S60 | Tested on devices | N70, N95, N96 |
| Category | Python | Subcategory | Location Based Services |
| Keywords (APIs, classes, methods, functions): cellid, gsm ,audio |
This is a small code snippet that exhibits how powerful the location module is. Location-based applications are very attractive and very powerful. So this article presents an example that shows you how to play a song repeatedly when the cell id changes. Using songs is just an example of what could be done automatically when the current cell id changes.
Note: The location module requires capabilities ReadDeviceData, ReadUserData and Location starting with S60 3rd Edition.
import location
import appuifw
import e32
import audio
class LocationInformerApp:
def __init__(self):
self.lock=e32.Ao_lock()
self.exitflag = 0
self.old_exit_key_handler=appuifw.app.exit_key_handler
self.old_app_body=appuifw.app.body
appuifw.app.exit_key_handler=self.set_exit
appuifw.app.title = u'Wiki Code'
def set_exit(self):
appuifw.app.body = self.old_app_body
self.exitflag=1
def run(self):
print u'*** Location Log ***'
prevLoc = u''
while not self.exitflag:
if prevLoc <> location.gsm_location():
print location.gsm_location()[3]
p = audio.Sound.open("c:\\test.mp3") #open the soundfile to play
p.play() # play the sound file for three times this is optional
prevLoc = location.gsm_location()
e32.ao_sleep(0.1)
appuifw.app.screen='normal'
lapp=LocationInformerApp()
lapp.run()
No related wiki articles found