×
Namespaces

Variants
Actions
Revision as of 06:53, 8 February 2012 by hamishwillee (Talk | contribs)

Archived:CellIds and songs in PySymbian

From Nokia Developer Wiki
Jump to: navigation, search


Article Metadata
Tested with
Devices(s): N70, N95, N96
Compatibility
Platform(s): S60
Platform Security
Capabilities: )
Article
Keywords: cellid, gsm ,audio
Created: gaba88 (29 Jul 2008)
Last edited: hamishwillee (08 Feb 2012)

Overview

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.

Preconditions

Note: The location module requires capabilities ReadDeviceData, ReadUserData and Location starting with S60 3rd Edition.


Code Snippet

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()

Postconditions

  • Initially, when the application starts it plays a song, and when the cellid changes the applications plays the song again right from the beginning.
  • The code can be easily modified such that the device plays different songs in different region that have different cellid.

References

63 page views in the last 30 days.
×