Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added MusicPlayer Script in Python #18

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions scripts/MusicPlayer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
**Project**

This is a basic music player project which is used to play music.

**Usage**

Once we run it, we get a GUI with 2 buttons. 'Select Songs' and 'o'. We select a song through the 'Select Songs' button and 'o' button is used to start or stop the song.
It supports Python3 and have used Pycharm for it.

**Note**

Audio files should be present in same folder as .py file is present.

**Dependencies**

Have to install library to get functional
- pip install pygame (in command line terminal)

**Screenshot**

![MusicPlayer](https://github.com/prathimacode-hub/Basic_Music_Player/blob/main/MusicPlayer.png)
28 changes: 28 additions & 0 deletions scripts/MusicPlayer/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from tkinter import *
import pygame
import os
from time import strftime
window = Tk()
pygame.mixer.init()
n=0
def start_stop():
global n
n=n+1
if n == 1:
song_name=songs_listbox.get()
pygame.mixer.music.load(song_name)
pygame.mixer.music.play(0)
elif (n%2)==0:
pygame.mixer.music.pause()
elif (n%2)!=0:
pygame.mixer.music.unpause()
l1=Label(window,text="Prathima Music Player", font="times 18")
l1.grid(row=1, column=1)
b2=Button(window,text='o', command=start_stop)
b2.grid(row=4, column=1)
songs_list=os.listdir()
songs_listbox=StringVar(window)
songs_listbox.set("Select Songs")
menu=OptionMenu(window, songs_listbox, *songs_list)
menu.grid(row=4, column=4)
window.mainloop()
3 changes: 3 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,7 @@ Your contribution should update this README with the following information, and
- pdf_merger<br />
A pdf merger to combine multiple PDFs into a single PDF.<br />
[Anshul Hajare](https://github.com/AnshulH)
- MusicPlayer<br />
A music player to select songs and play music.<br />
[Prathima Kadari](https://github.com/prathimacode-hub)
<!-- scriptsstop -->