Robotics & Coding classes for Kids from Industry Experts | Roboprenr | Best Classes | Bangalore | India

Build MP3 Player using Python

Build MP3 Player using Python

Code snippets to build MP3 player featues:

1. How to play a song?
A. There are a few options available in Python to play song but the best is mixer that comes with Pygame.
from pygame import mixer


mixer.init()
        mixer.music.load(current_song)
        mixer.music.set_volume(current_volume)
        mixer.music.play()
except Exception as e:
        print(e)


2. How to choose song file from file system A. Use filedialog


from tkinter import filedialog
filename=filedialog.askopenfilename(initialdir="/Users/dhananjay",
title="Please select a song")

No Comments

Leave a Comment