Archived:CellIds and songs in PySymbian
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.
self.exitflag = 0
appuifw.app.title = u'Wiki Code'
appuifw.app.body = self.old_app_body
print u'*** Location Log ***'
prevLoc = u''
while not self.exitflag:
if prevLoc <> location.gsm_location():
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()
- 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.