G9Adv-Building An MP3 Player in Python (Word Version)
G9Adv-Building An MP3 Player in Python (Word Version)
Aim
This section will introduce you to the concept of programming events, prototypes and feedback. You will
learn these concepts through designing a GUI of an MP3 player using Python.
Learning outcomes
• Create prototypes that use algorithms to solve a range of computational problems by applying
prior student knowledge.
• Develop computational artefacts using an iterative process for practical intent and personal
expression using events to initiate instructions.
• Explain methods that can be implemented to gather feedback on a program from a broad
audience.
Prior knowledge
• Algorithms
• Python programming
ADVANCED WORKBOOK
My STREAM focus
44
Research various examples for the GUI of an MP3 player. Use your research to gather
some information about the various layout available using images or text. Paste your findings
in the space below.
ADVANCED WORKBOOK
Use the research results completed in Activity 1.4.1 to sketch the layout of the GUI for
your MP3 player.
Remember that you will be designing a very basic GUI with the following elements on the
window:
46
The algorithm for your MP3 player is shown in the table below but in the wrong order.
Organise the steps in the correct order in the table below. The first and last steps are done for
you.
ADVANCED WORKBOOK
Add the title to the player window.
Close button will automatically clear the song list and will stop playing the song.
47
Copy and paste the following code to build your MP3 player.
root = Tk()
root.title('MP3 player')
root.geometry("500x400")
def play():
pygame.mixer.music.load("write the name of the audio file here")
pygame.mixer.music.play(loops=0)
title=Label(root,text="MyMusicPlayer",bd=9,relief=GROOVE,
font=("times new roman",50,"bold"),bg="white",fg="green")
title.pack(side=TOP,fill=X)
output.
48
For the MP3 player which you have developed using Python, answer the following questions:
ADVANCED WORKBOOK
4
Section
Chapter 1
49
List three things you have learned and two things you have enjoyed.
Three things I have learned:
1-
2-
3-
Key skills
I don’t I’m an
Learning outcomes (Please tick the box to show your I understand.
understand. expert.
understanding of the skills below.)
Teacher's comment:
Chapter 1
50
Copyright © Ministry of Education – United Arab
Emirates