The application to be developed will have the following functionalities: 1. An Input box to accept the path for the file to be played. 2. The ability to play a selected file when entered by the user. Here we go. First comes the imports. Since both UI and Sound are required, the appuifw and audio modules need to be imported. from appuifw import * import audio Next we need to show the entry box to the user and get the path entered by him or her. To display the text box, we can use the query component. The first argument is the prompt to be shown and the second argument is the type of query. The type can be ‘text’, ’date’, ’time’, ’float’ etc. Here the type will be text as we need textual data i.e. a string. The value returned by the query component will be stored in a variable named data. from appuifw import * import audio data=query(u’Enter the path of the file to be played’, ‘text’) Now we need to load the file. For that we need to call the load method of sound. As discussed in the previous section every method in the sound module is static. We will also check whether the user clicked cancel. If cancel has been clicked, then data will contain null. from appuifw import * import audio data=query(u’Enter the path of the file to be played’, ‘text’) if data is not Null: Sound.load(data) else: note(u’Give the path name’, ‘info’) Next let us tell Symbian to play it. from appuifw import * import audio data=query(u’Enter the path of the file to be played’, ‘text’) if data is not Null: Sound.load(data) Sound.play() else: note(u’Give the path name’, ‘info’) That completes our application. Though it is small, it introduces several important concepts of PyS60. In the coming discussions, I will go into more depth on each module. Till then…
blog comments powered by Disqus |
|
|
|
|
|
|
|