DEV Community

Cover image for How to make Music Player in Python
Arpit
Arpit

Posted on • Edited on • Originally published at codesnail.com

9 1

How to make Music Player in Python

Hello Programmers
Originally posted here with detail: https://www.codesnail.com/how-to-make-music-player-in-python/

# Music player in python

from pygame import mixer

mixer.init()
# --------------------------Path of your music
mixer.music.load("PYAR-HUA-IKRAAR-HUA.mp3")
mixer.music.set_volume(0.5)
mixer.music.play()

while True:
    print("Press 'p' to pause")
    print("Press 'r' to resume")
    print("Press 'v' set volume")
    print("Press 'e' to exit")

    ch = input("['p','r','v','e']>>>")

    if ch == "p":
        mixer.music.pause()
    elif ch == "r":
        mixer.music.unpause()
    elif ch == "v":
        v = float(input("Enter volume(0 to 1): "))
        mixer.music.set_volume(v)
    elif ch == "e":
        mixer.music.stop()
        break

# Follow @code_snail
Enter fullscreen mode Exit fullscreen mode

For more detailed and step by step visit: How to make music player in Python

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more