×
Namespaces

Variants
Actions

Archived:CellIds and songs in PySymbian

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngAquivado: Este artigo foi arquivado, pois o conteúdo não é mais considerado relevante para se criar soluções comerciais atuais. Se você achar que este artigo ainda é importante, inclua o template {{ForArchiveReview|escreva a sua justificativa}}.

All PySymbian articles have been archived. PySymbian is no longer maintained by Nokia and is not guaranteed to work on more recent Symbian devices. It is not possible to submit apps to Nokia Store.

Article Metadata
Tested with
Devices(s): N70, N95, N96
Compatibility
Platform(s): S60
Article
Keywords: cellid, gsm ,audio
Created: gaba88 (29 Jul 2008)
Last edited: hamishwillee (31 May 2013)

Contents

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

This page was last modified on 31 May 2013, at 04:02.
62 page views in the last 30 days.
×