Chapter 5. Audio Player

Let's now build an audio media player!

Our application should have features offered by typical media players, such as play, pause, fast forward, rewind, next, mute, volume updates, and more. Our player should let the listener easily access individual media files or media library from his or her local drive.

In addition to this, our player should be able to scan entire directories for a song and accordingly, auto update the playlist with all supported formats. All this and more.

Let us start our project!

Mission Briefing

On completion our player will look as follows:

Mission Briefing

Our audio player will be capable of playing audio files in AU, MP2, MP3, OGG/Vorbis, WAV, and WMA formats. It will have all the controls that you would expect of a small media player.

We will use cross-platform modules to write our code. This will ensure that our player can play audio files on Windows, Mac OS X, and Linux platforms.

Why Is It Awesome?

In addition to getting to hear good music while testing our code, this project will introduce us to several new ideas related to GUI programming with Tkinter.

For one, we get to work with new sets of widgets, such as the Listbox, Progressbar, Scale, Radiobutton, and PMW Balloon widget.

We also take a look at the power of the Canvas widget in accommodating and precise positioning of other widgets within it.

Towards the end of the project, we take a look at a Tkinter extension named PMW. We also discuss some more Tkinter extensions that we do not use here, but are good to have in our GUI programming arsenal.

Though not a topic for this book, we also get a brief insight into the world of audio programming with Python, which necessarily looks at how to work with external libraries and API implementations.

Your Hotshot Objectives

Some of the key objectives outlined for this project include:

  • Reinforcing our experiences and learning from previous projects
  • Working with new set of widgets, such as Listbox, Scale, Progressbar, and Radiobutton
  • Getting to know more of the Canvas widget
  • Working with external APIs
  • Getting to know about some common Tkinter extensions, such as PMW, WCK, Tix, and others
  • Learning to refactor code at each stage of development

Mission Checklist

We will use the following additional libraries for this project:

Pyglet for audio manipulation

Window users can download and install binary packages for pyglet from:

http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyglet

Mac OS X and Linux users should download and compile pyglet from the source ZIP file available at:

http://www.pyglet.org/download.html

When installing from source, you will also need to add the AVbin.dll to your current program directory. The link to the DLL file is also available at the preceding download page.

PMW Tkinter extension

We will be using Python mega widgets (PMW) Tkinter extension to code some widgets features not available in core Tkinter. PMW must be installed from the source package for all platforms. The package can be downloaded at:

http://sourceforge.net/projects/pmw/files/Pmw/Pmw.1.3.3/

Note

We use Version 1.3.3 in our application, and other versions of PMW may not be compatible with our code.

Additional font

This is an optional component meant only to augment our styling. We install a font to mimic the font of a digital clock. We have used the following font for this project:

http://www.dafont.com/ds-digital.font

After you have installed pyglet and PMW, execute the following command from your Python shell:

>>> import pyglet, Pmw

If the command executes without any error message, you are ready to code your media player.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.144.248