Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 576b573

Browse files
a simple music player
1 parent 7d76916 commit 576b573

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed
4.63 MB
Binary file not shown.

‎Music_Player/README.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Music Player
2+
3+
A simple music player implemented in Python using the pygame library.
4+
5+
## Description
6+
7+
The Music Player is a basic command-line application that allows users to play music files in popular formats such as MP3. It utilizes the pygame library for audio playback functionality. The player provides options to play music, stop the current playback, and exit the program.
8+
9+
## Features
10+
11+
- Play music files in popular formats such as MP3.
12+
- Stop the current music playback.
13+
- Simple command-line interface.
14+

‎Music_Player/music.py‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import pygame
2+
3+
def play_music(file_path):
4+
pygame.mixer.init()
5+
pygame.mixer.music.load(file_path)
6+
pygame.mixer.music.play()
7+
8+
def stop_music():
9+
pygame.mixer.music.stop()
10+
11+
def main():
12+
print("Simple Music Player")
13+
print("-------------------")
14+
15+
while True:
16+
print("1. Play Music")
17+
print("2. Stop Music")
18+
print("3. Exit")
19+
20+
choice = input("Enter your choice: ")
21+
22+
if choice == "1":
23+
file_path = r"./Otnicka_-_Peaky_Blinder_(lyrics)___i_am_not_outsider_i'm_a_peaky_blinder(256k).mp3"
24+
play_music(file_path)
25+
elif choice == "2":
26+
stop_music()
27+
elif choice == "3":
28+
stop_music()
29+
break
30+
else:
31+
print("Invalid choice. Please try again.")
32+
33+
if __name__ == "__main__":
34+
main()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /