Skip to content

Added Music Player #166

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

Open
wants to merge 1 commit into
base: main
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 Projects/Music-Player/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Shitij Agrawal

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
33 changes: 33 additions & 0 deletions Projects/Music-Player/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!--Please do not remove this part-->
![Star Badge](https://img.shields.io/static/v1?label=%F0%9F%8C%9F&message=If%20Useful&style=style=flat&color=BC4E99)
![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)

# Music Player


## 🛠️ Description
A simple music player in python which enables you to play, next, back, pause, resume the music

## ⚙️ Languages or Frameworks Used
This project is created using python programming language.
Modules : tkinter, vlc and glob

## 🌟 How to run
Running the script is really simple! Just open a terminal in the folder where your script is located and run the following commands:

```sh
pip install -r requriment.txt
```

```sh
python music_player.py
```


## 📺 Demo
<p align="center">
<img src="https://github.com/mr-shitij/Music-Player-In-Python/blob/main/images/Screenshot%20from%202022-10-02%2011-19-40.png" width=70% height=70%>

## 🤖 Author
[mr-shitij](https://github.com/mr-shitij)

Binary file added Projects/Music-Player/images/backward.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Projects/Music-Player/images/forward.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Projects/Music-Player/images/pause.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Projects/Music-Player/images/play.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Projects/Music-Player/images/stop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 75 additions & 0 deletions Projects/Music-Player/music_player.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import glob
import tkinter as tk
from tkinter import *
import vlc


def last(list):
return list[-1]


def music_name():
global my_music, music_number
return last(my_music[music_number].split('/'))


def play_music():
global music_number, my_music, player, instance
to_play = my_music[music_number]
media = instance.media_new(to_play)
player.set_media(media)
player.play()


def pause_music():
player.pause()


def next_music():
global music_number, my_music, music_label
if music_number < len(my_music) - 1:
music_number += 1
music_label.config(text=str(music_name()))


def previous_music():
global music_number, my_music, music_label
if music_number > 0:
music_number -= 1
music_label.config(text=str(music_name()))


music_number = 0

window = Tk()
window.geometry('330x120')
window.resizable(False, False)
window.title('Mp3 Player')

instance = vlc.Instance()
player = instance.media_player_new()

my_music = glob.glob('/home/shitij_agrawal/Music/*.mp3') # path to music folder

play_image = PhotoImage(file='images/play.png')
pause_image = PhotoImage(file='images/pause.png')
forward_image = PhotoImage(file='images/forward.png')
backward_image = PhotoImage(file='images/backward.png')
stop_image = PhotoImage(file='images/stop.png')

music_label = tk.Label(window, text=music_name())

play = tk.Button(window, image=play_image, command=play_music)
pause = tk.Button(window, image=pause_image, command=pause_music)
forward = tk.Button(window, image=forward_image, command=next_music)
backward = tk.Button(window, image=backward_image, command=previous_music)
stop = tk.Button(window, image=stop_image, command=lambda: sys.exit())

play.place(x=130, y=50)
pause.place(x=10, y=50)
forward.place(x=190, y=50)
backward.place(x=70, y=50)
stop.place(x=250, y=50)
music_label.place(x=10, y=0)

window.mainloop()
1 change: 1 addition & 0 deletions Projects/Music-Player/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python-vlc==3.0.12118