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
For more detailed and step by step visit: How to make music player in Python
Top comments (0)