Music Album
Description:
This application creates a Music Album protected by a password. It offers facilities for adding tracks to an album (tracks are by default read from c:\\music), this happens in the new_album() function. Tracks from this list are added to a global album list variable.
When the open() function is invoked the user is prompted to enter a password, which must correspond to the global system_password value. When access has been granted the user can view a list of files in the album and choose to play anyone of the files in the album.
The set_password() function does as the name implies change the value of the global system_password value.
###### Music album python script by
###### Morten Vejen Nielsen (mvejen@cs.aau.dk)
###### Jørn Martin Rasmussen (joern25@cs.aau.dk)
###### Nikolaj Andersen (nikko@cs.aau.dk)
###### import all modules needed
import appuifw
import e32
import os
import audio
import graphics
###### set the screen size (in this example, to large)
appuifw.app.screen='large'
from appuifw import *
from graphics import *
###### Passwords, default password set to 'password'
system_password = u"password"
#Path to store screenshots
sc_path = u'c:\\gfx\\'
#Global album value
album = []
###### Function for playing songs in the album list
def open():
#Validate user password
password = query(u"Enter password","code")
if password == system_password:
#Show album list
choice = appuifw.selection_list(album, search_field=0)
#Play selected song
song = audio.Sound.open(album[choice])
song.play()
else:
note("Wrong password supplied", "error")
###### Adds a song to our album
def addToAlbum(fileName):
album.append(fileName)
###### Shows list of files that can be added to album
def new_album():
appuifw.app.title = u"Add song to album"
###### Open directory listing of z:\music and show results in menu
path = u'c:\\music\\'
files = map(unicode,os.listdir(path))
#Create and show selectionList
choice = appuifw.selection_list(files, search_field=0)
#Add selected track to album
fileName = path + files[choice]
addToAlbum(fileName)
####### Changes the system password needed to play songs
def set_password():
#Change global value holding system password
globals()["system_password"] = query(u"Enter password","code")
note(u"Password changed","info")
###### Show main menu
app.menu = [(u"Add to album", new_album),(u"Open", open),(u"Set Password", set_password)]
##### create and set an exit key handler
def exit_key_handler():
app_lock.signal()
appuifw.app.set_exit()
##### set the title
appuifw.app.title = u"Music Album"
#####
app_lock = e32.Ao_lock()
appuifw.app.exit_key_handler = exit_key_handler
app_lock.wait()




