loading...
Cover image for How to make Music Player in Python

How to make Music Player in Python

codesnail profile image CodeSnail (Arpit) ・1 min read

Hello Programmers

# 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

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

Discussion

markdown guide