diff --git a/Projects/Music-Player/LICENSE b/Projects/Music-Player/LICENSE new file mode 100644 index 0000000..e7e458f --- /dev/null +++ b/Projects/Music-Player/LICENSE @@ -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. diff --git a/Projects/Music-Player/README.md b/Projects/Music-Player/README.md new file mode 100644 index 0000000..55a64e9 --- /dev/null +++ b/Projects/Music-Player/README.md @@ -0,0 +1,33 @@ + +![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 +

+ + +## 🤖 Author +[mr-shitij](https://github.com/mr-shitij) + diff --git a/Projects/Music-Player/images/backward.png b/Projects/Music-Player/images/backward.png new file mode 100644 index 0000000..e168039 Binary files /dev/null and b/Projects/Music-Player/images/backward.png differ diff --git a/Projects/Music-Player/images/forward.png b/Projects/Music-Player/images/forward.png new file mode 100644 index 0000000..244d71c Binary files /dev/null and b/Projects/Music-Player/images/forward.png differ diff --git a/Projects/Music-Player/images/pause.png b/Projects/Music-Player/images/pause.png new file mode 100644 index 0000000..79f1e80 Binary files /dev/null and b/Projects/Music-Player/images/pause.png differ diff --git a/Projects/Music-Player/images/play.png b/Projects/Music-Player/images/play.png new file mode 100644 index 0000000..4f8758f Binary files /dev/null and b/Projects/Music-Player/images/play.png differ diff --git a/Projects/Music-Player/images/stop.png b/Projects/Music-Player/images/stop.png new file mode 100644 index 0000000..a36ae83 Binary files /dev/null and b/Projects/Music-Player/images/stop.png differ diff --git a/Projects/Music-Player/music_player.py b/Projects/Music-Player/music_player.py new file mode 100644 index 0000000..eee923c --- /dev/null +++ b/Projects/Music-Player/music_player.py @@ -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() diff --git a/Projects/Music-Player/requirements.txt b/Projects/Music-Player/requirements.txt new file mode 100644 index 0000000..0759759 --- /dev/null +++ b/Projects/Music-Player/requirements.txt @@ -0,0 +1 @@ +python-vlc==3.0.12118