In Today's Post, I am going to show you how we can create a simple music player app using python and pyglet module.
Listening Music is my favorite way to make my mind stress free and I hope you also like music listening habits. basically, In today's busy life, music is really very beautiful part of our life and of course to run any music.. music playing app is one of the basic requirement.
As Every One Know! Education and Skill learning is endless And To Polish Our Programming And Problem Solving Skills, We Always need to takes New difficult Steps Whenever it's important. Actually, I am Saying this Because Today's topic can be seen very difficult to newbies because, in this tutorial, I am going to use a new module named pyglet. (Description About Pyglet Given Below)
In This tutorial, we will learn about how we can create cross-platform media player using python and pyglet? Or how to create music player using python?Or how to play music using pyglet? etc etc.
and after reading this tutorial don't forget to follow our blog on social media because we create these types of projects regularly.
Python Is Really Very Interesting Language Because this language provides usability to write cross-platform codes that can run on all types of the system without even doing any big changes in codes. Yeah! Yeah, That's Why I like Python.
And Yes, With python we can do many interesting things like
- Creating New GUI (Graphical User Interface) Apps,
- Different Types Of Automation Apps,
- Web scrapers,
- and Penetration Testing Tools Also.
- Etc Etc.
So, If You Are Really Very Interested In Creating New Things In Python Language. Then, I think You Need to check this project list
or Visit These Posts Also.
Now, Let's Come To Our Main Point.
How it's Going To Work? (Python Media Player App).
Before Starting Our Juicy Part Of Tutorial Let's Take a look at Important Questions, I Want To Clear These Important Queries So That You Can Understand all Stuff Easily.
Q 1. What is pyglet? Or Why I am using pyglet?Ans. As Wikipedia says “Pyglet is a library for the Python programming language that
provides an object-oriented application programming interface for the creation of games
and other multimedia applications. Pyglet runs on Microsoft Windows, Mac OS X, and Linux;
it is released under BSD Licence.""
In Simple Words, This Library basically provides us various types of functionality, Capabilities, Systems, scripts Required to make a rich feature loaded Games And One of the major features of this modules is its cross-platform capability with Object Oriented Programming Interface, And a wide range of media file handling capabilities.
Well, There are some more other features also available like It supports windowed and full-screen operation, and multiple monitors also. More Images, video, and sound files in a range of formats can be done natively, with more additional capabilities supplied by the optional AVbin plugin, which uses the
Libav package to provide support for audio formats including
Windows Media Audio, and video formats such as
Q 2. What Is AVBin plugin?
Ans. AVBin Plugin is a special compiled library that provides us cross-platform support function API to perform various functions, necessary to play music files. In Other Words, You Just need to store only one point in your mind that This File Is Nessecery To Play A Music File Through Pyglet Library.
Q 3. Why I Select Pyglet Module To Make A Music Player?
Well Actually Features List Is Big But Here, I am writing only a few points
So Our Pyglet Concept is Clear.
- Cross-Platform Support
- Object-Oriented Programming
- Easy To Setup
- Extra Extra.
Now, Let's Move Ahead and take look at other modules.
Here For Graphics Of this App,
I am Using Tkinter. Basically, Tkinter is a Python Wrapper Over Tk/Tcl Which Provide us the Graphical Support. Well In simple words, Tkinter module provides us the power to make a Simple Or Advance Graphical Interface For Users. But There are many other libraries are also available like WxPython, GTK Etc Therefore Next Question Comes To our Mind. Why I used Tkinter? because
- Tkinter is simple,
- Rich Features Available,
- Wide Variety Of Widgets,
- Comes Pre-Installed In Many Operating System,
- Cross-Platform Supported,
- Light Weight To Use and
- Easy to use.
if you are new and don't know how to use Python Tkinter Module.
Then, These Posts Can Help You In Understanding Tkinter Modules.
Now, Before Codes Section Let's Take a look at the media player. Here I am Sharing Some Screen Shots
As You Can See In Screen Shot, I Added Many Extra Features in Tkinter Like Show/Hide Panel List.
or If You Want To See This App, Live Running On Desktop
Then Check This Video.
Q 3. How This Python Media Player Working? Ans. Basically In This Media Player App, As I already described in above section I am going to use Python Tkinter Module For Creating Beautiful Graphics And Using Pyglet For Playing Music Files Because Tkinter Not Comes with music file handling capabilities.Actually, Tkinter Module does not provide us the power to play any sound file. Therefore for playing any sound file, we have to take help from a third party module called the pyglet library.
In Simple Words, To make any media player using Tkinter and pyglet library. You Just Need To Create A Function That Can Handle And Play All Provided Media Files And Another function To Create A Beautiful Graphics That Can Control Previous Functions Efficiently.
And To Create This Project, Easy I used a simple technique called Divide And Conquer.!
I divided all Coding functions and problems into Small Modules and after creating all function in the separate script I just combine all together to make a powerful program.
Hence, This Techniques Made My Complex Problems Very Easy!
readers, Because This Project is Very Difficult To Explain Completely in One post So, I decided to write separate posts for separate functionality and also to left further exercise to the reader. hence, you can also suggest me which topic of this project you think needs more focus and explanation so thatIi can write another tutorial on it.Click Here To Check How To Play Music with Pyglet Module.
For Downloading Source Code Check My Github Repo