▶️ Watch Entire Tkinter Playlist ✅ Subscribe To My RUclips Channel: bit.ly/2UFLKgj bit.ly/2IGzvOR ▶️ See More At: ✅ Join My Facebook Group: Codemy.com bit.ly/2GFmOBz ▶️ Learn to Code at Codemy.com ✅ Buy a Codemy T-Shirt! Take $30 off with coupon code: youtube1 bit.ly/2VC9WUN ▶️ Get The Code bit.ly/3fLFQ8p
at 18:09 instead of .replace() method we can use song_name=song.split('/')[-1].split('.')[0] to get the song name , since we can choose the audio from any folder in the pc and hard coding to replace the string could break the code right? and there is no need to join the string back in play() too because we haven't modified the contents of song .
@@mrtrader3661 def findfiles(filename): filename=f'{filename}.mp3' search_path=["F:/","C:/","D:/"] #insert your drives in list
for i in (search_path): for root,dir, files in os.walk(i): if filename in files: return(os.path.join(root, filename)) def play(): song=music_box.get(ACTIVE) #getting the path of file Song=findfiles(song) pygame.mixer.music.load(Song) pygame.mixer.music.play(loops=0)
Hi.. Following my earlier post. My songs are located in a sub-directory many levels down. I did not fancy typing in location of songs directory in the play function. I created a global string variable with name of directory where songs are located when adding the songs. I used the 'song' string and 'song title' string , the difference between the lengths of these gives length of string in 'song' string containing the directory. From this I built a string variable which i called song_dir. This I used in play function i.e. song=song_dir + f '{song}.mp3' , then loaded 'song' into pygame player. This should work as long as all songs are in same directory. Hope people find this useful. BY THE WAY I AM FOLLOWING THE TKINTER CODEMY TUTORIALS FROM THE START. I INTEND TO FOLLOW TO END. ..... EXCELLENT TUTORIALS IN SMALL EASY TO FOLLOW CHUNKS . *** THANK YOU ***
Would it be possible to create a list for the buttons and then run a loop to grid them? Would a tuple work in this situation? Not that performance is even a factor on such a basic program but thinking down the line of you want to add “features” for example. Sorry I’m still learning Python lol
Thanks for your TUT! i have learned a lot and added some stuff more useful to me :P like auto playing the entire playlist 1 file after the other, instead of 1 file at a time, i am a rather new to python :P and your guides were very easy
@@Codemycom Picture of your guide in use on my Raspberry pi and waveshare touch screen, this is last nights work. Ive made the icons bigger and replaced them with other ones :P. Ive also added the folder icon to glob all flac files in a dir instead of selecting all files, whcih is kinda tricky on a touch display :) imgur.com/a/bGczD2A
is thee a way to change the colour of the slider widget in the progress slider? (just the little nub that slides) ive googled many methods but i keep getting errors and cant change any colours on the progress slider
The script runs fine without error message, but in the stop function the listbox is not cleared when stop button pressed. Couldn't see where I'm wrong.
Thanks for these videos. They are very helpful. I try something and i have to use pygame get pos() func. But get pos func is updated and i cant figure it out. I am so confuse right now. Can you say what version is used these videos?
Sorry, I don't recall. This video was from June 2020, so whatever the pygame version was then. You can check the changelog of the pygame docs to see what version that was.
For some odd reason the song menu isn' popping up when I start the mp3 player but the mp3 player runs fine. Could it be because I am coding on a mac and the mac and windows are different?
Sir... What is the difference between using ImageTk.PhotoImage(Image.open()) and only PhotoImage() .... Will both work for adding images to buttons ? Thank u sir....!
Hi.. I want to run one mp3 file multiple time(user entery), and want to know what is the count. I have written below code for multiple time mp3 file execution but not working. Can you please pointout the issue. "i=0 while i
Why when I write python player.py Git says: Traceback (most recent call last): File "I hid this line", line 3, print import pygame ModuleNotFoundError: No module named 'pygame'
Plz help. The music was playing till yesterday. Suddenly it is showing that "failed loading libmpg123.dll.: %1 is not a valid win32 application." I was able to play the music for two days. This error is showing up from today. Can you plz help me??😢😢😢😢
i want to ask, when i tried to play the music, it says pygame.error: mpg123_seek: Invalid RVA mode. (code 12) can you tell me the reason why? btw thanks for your tutorial video they're really great
Sir , can you guide to how to make a play pause button which can play or pause the songs that i play on youtube or on any online platform because these buttons only work for downloaded songs
hello! your videos content are good .But we need you to explain about the libraries you import and the keywords and functions you use .I am a begineer and we dont understand the function of the keywords u use .Hope u improve them!! thank you :)
Having an error Pygame.error: failed loading libmpg123-0.dll: the file cannot be accessed by the system. Please help me out , code is working but its not playing my song due to this error.
@@Codemycom drive.google.com/file/d/1fZS-nWD14jeNWgxzHlBZIfyGTKAtBWzo/view?usp=drivesdk Here is the code drive.google.com/file/d/1QVa7LfFv91MLCKYVkb4CPAeiEqKiQH5_/view?usp=drivesdk Here is the output
Great Tutorial! Can you make a video on making a mindmap / automatically generate a mindmap from given data. I've been stuck with this problem for a while
Codemy.com I would like to have a home screen and different pages. I’ve seen tutorials where they’ve used raise_frame but it looked kinda confusing. Thanks
Hey, had the same problem. After some searching, the only thing that I could figure out from others was that pygame can no longer run mp3 files for licensing issues. Instead, just use .ogg files. Works just as well, no issues so far.
▶️ Watch Entire Tkinter Playlist ✅ Subscribe To My RUclips Channel:
bit.ly/2UFLKgj bit.ly/2IGzvOR
▶️ See More At: ✅ Join My Facebook Group:
Codemy.com bit.ly/2GFmOBz
▶️ Learn to Code at Codemy.com ✅ Buy a Codemy T-Shirt!
Take $30 off with coupon code: youtube1 bit.ly/2VC9WUN
▶️ Get The Code
bit.ly/3fLFQ8p
at 18:09 instead of .replace() method we can use song_name=song.split('/')[-1].split('.')[0] to get the song name , since we can choose the audio from any folder in the pc and hard coding to replace the string could break the code right?
and there is no need to join the string back in play() too because we haven't modified the contents of song .
Thank You! This is what I was looking for.
Thank you
if you use it this way how to get the file path when needed to play a song?
@@mrtrader3661
def findfiles(filename):
filename=f'{filename}.mp3'
search_path=["F:/","C:/","D:/"] #insert your drives in list
for i in (search_path):
for root,dir, files in os.walk(i):
if filename in files:
return(os.path.join(root, filename))
def play():
song=music_box.get(ACTIVE)
#getting the path of file
Song=findfiles(song)
pygame.mixer.music.load(Song)
pygame.mixer.music.play(loops=0)
rgwe
Hi.. Following my earlier post. My songs are located in a sub-directory many levels down. I did not fancy typing in location of songs directory in the play function. I created a global string variable with name of directory where songs are located when adding the songs. I used the 'song' string and 'song title' string , the difference between the lengths of these gives length of string in 'song' string containing the directory. From this I built a string variable which i called song_dir. This I used in play function i.e. song=song_dir + f '{song}.mp3' , then loaded 'song' into pygame player. This should work as long as all songs are in same directory. Hope people find this useful.
BY THE WAY I AM FOLLOWING THE TKINTER CODEMY TUTORIALS FROM THE START. I INTEND TO FOLLOW TO END. ..... EXCELLENT TUTORIALS IN SMALL EASY TO FOLLOW CHUNKS . *** THANK YOU ***
Another great tutorial! I really Love your teaching style! Love from Bahrain ❤️❤️
Thanks!
nice another Arabic country is learning programming from morocco
Would it be possible to create a list for the buttons and then run a loop to grid them? Would a tuple work in this situation? Not that performance is even a factor on such a basic program but thinking down the line of you want to add “features” for example. Sorry I’m still learning Python lol
Thanks for your TUT!
i have learned a lot and added some stuff more useful to me :P like auto playing the entire playlist 1 file after the other, instead of 1 file at a time, i am a rather new to python :P and your guides were very easy
Glad it helped!
@@Codemycom Picture of your guide in use on my Raspberry pi and waveshare touch screen, this is last nights work. Ive made the icons bigger and replaced them with other ones :P. Ive also added the folder icon to glob all flac files in a dir instead of selecting all files, whcih is kinda tricky on a touch display :) imgur.com/a/bGczD2A
is thee a way to change the colour of the slider widget in the progress slider? (just the little nub that slides) ive googled many methods but i keep getting errors and cant change any colours on the progress slider
How do you code the playlist and play button so that your music choice isn't limited to a specific directory?
The script runs fine without error message, but in the stop function the listbox is not cleared when stop button pressed. Couldn't see where I'm wrong.
Thanks for these videos. They are very helpful.
I try something and i have to use pygame get pos() func. But get pos func is updated and i cant figure it out. I am so confuse right now. Can you say what version is used these videos?
Sorry, I don't recall. This video was from June 2020, so whatever the pygame version was then. You can check the changelog of the pygame docs to see what version that was.
Thank you very much sir.
your tutorials are very easy to Undestand.
You are perfect.
So nice of you, thanks!
For some odd reason the song menu isn' popping up when I start the mp3 player but the mp3 player runs fine. Could it be because I am coding on a mac and the mac and windows are different?
Sir... What is the difference between using ImageTk.PhotoImage(Image.open()) and only PhotoImage() .... Will both work for adding images to buttons ? Thank u sir....!
Both seem to work
I don't know how to install pygame and compiler. Is there any video of yours explaining this..?
pip install pygame from the terminal
Hi.. I want to run one mp3 file multiple time(user entery), and want to know what is the count. I have written below code for multiple time mp3 file execution but not working. Can you please pointout the issue. "i=0
while i
Why when I write python player.py Git says:
Traceback (most recent call last):
File "I hid this line", line 3, print
import pygame
ModuleNotFoundError: No module named 'pygame'
Did you forget to pip install pygame?
Plz help. The music was playing till yesterday. Suddenly it is showing that "failed loading libmpg123.dll.: %1 is not a valid win32 application."
I was able to play the music for two days. This error is showing up from today. Can you plz help me??😢😢😢😢
Restart your computer
Whenever i add images/back50.png even i have done it right it says couldn't open it : no such file or directory found
Do you have that image, sitting in that directory?
pygame.error: mpg123_seek: Invalid RVA mode. (code 12) i'm getting this error. Looking forward for help :)
you'll have to google that error
I am getting an RVA error whenever I try to play the song. Any suggestions???
Google the exact error
Amazing! Thank you very much and congrats for the whole knowledge..
Glad you liked it!
How can i add function that search music from the playlist?
Failed loading libmpg123-0.dll: The specified module could not be found. How to resolve this error....?
Google the error
Please which app are you using for the music player?
We care building the app
i want to ask, when i tried to play the music, it says
pygame.error: mpg123_seek: Invalid RVA mode. (code 12)
can you tell me the reason why? btw thanks for your tutorial video they're really great
You'll have to google the error
Same thing happens to me
Sir , can you guide to how to make a play pause button which can play or pause the songs that i play on youtube or on any online platform because these buttons only work for downloaded songs
No, sorry
hello! your videos content are good .But we need you to explain about the libraries you import and the keywords and functions you use .I am a begineer and we dont understand the function of the keywords u use .Hope u improve them!!
thank you :)
No, you don't need to know that in order to use them.
i am using visual studio and can not import pygame and it returns that is not recognized as internal or external comand
someone can help me with that
@@marcioandre6469 Yeah, don't use visual studio
thank you so much.. GREAT TUTORIAL!!!
Welcome!
Wow, that's amazing! Can you in the next videos create application like pdf reader or doc reader using tkinter? If you can I will be glad :)
May do something like that in the future
Great work walter white im learning a lot from you
Ha!
sir i want to ask about how to fix the pygame.error: mpg123_seek: Invalid RVA mode.
no clue, you'll have to google the error
@@Codemycom thx sir
actually the song is corrupted sir
@@Edelity Ah, there you go then.
Excellent tutorial. I wish I could get the source code as you have provided in other tutorials.
It's in the pinned comment of every video.
thank you so much for help. have a great day!
Smash the Like button python fans! Doesn't cost you a thing. Great Python tkinter tutorial! cheers!
Thanks!
Great Tutorial! one question,
can you explain how can i add an image as a background instead of colors in the song box?
just replace colour with the photo image
or try out background="image or path"
this might help
Thank I'm learning a lot from your videos
Glad to hear it
Can you please explain how can we add shuffle option in this?
You'd need to create a random number and use it to play that particular song
Thank you very much I hope you will continue with python
That's the plan!
This Is very cool !! 😎
Thank you ! 🥇
Glad you liked it!
Has the source code of this course not been published in Github ?
yes, it's there
Having an error
Pygame.error: failed loading libmpg123-0.dll: the file cannot be accessed by the system.
Please help me out , code is working but its not playing my song due to this error.
Did you try googling the error?
Yes but i didn't found any solution
I tried all the alternative provided to solve this but its saying "couldn't open ABC.mp3"
@@BasKuchKarnaH Is that an actual mp3 file? (Not a wav file or something else?) is it actually sitting in that directory?
The Best tutorial👍👍👍👍👍
I have a problem I code exactly like you but my button doesn't show the icon it shows a border only
Please help me
Then your code isn't exactly like mine. Do you have the images sitting on your computer?
@@Codemycom drive.google.com/file/d/1fZS-nWD14jeNWgxzHlBZIfyGTKAtBWzo/view?usp=drivesdk
Here is the code
drive.google.com/file/d/1QVa7LfFv91MLCKYVkb4CPAeiEqKiQH5_/view?usp=drivesdk
Here is the output
@@Codemycom Did you Get an answer?
@@nemithafernando5756 I didn't read your code. You'll have to do that yourself.
Thanks a lot for your tutorial !
Welcome!
Just one word, Amazing!!!!
Thanks!
sry guys, I am getting "Everyrhing", except what is "root" and why we put it everywhere?
root is the name of the app
here's an error (import tkinter import filedialog) ,,,, please give a solution.
you imported filedialog incorrectly. Do it exactly as I do it in the video.
Sir I am having this error, can u help me
pygame.error: Couldn't open 'D:/Music/
from tkinter import *
import pygame
from tkinter import filedialog
root = Tk()
root.title('Mp3 Player')
root.iconbitmap('C:/')
root.geometry('500x300')
# Initialize Pygame Mixer
pygame.mixer.init()
# Add Song Function
def add_song():
song = filedialog.askopenfile(initialdir='D:/Music/', title='Choose a song', filetypes=(('mp3 Files', '*.mp3'), ))
# Add songs to list box
song_box.insert(END, song)
# Play selected song
def play():
song = song_box.get(ACTIVE)
song = f'D:/Music/{song}.mp3'
pygame.mixer.music.load(song)
pygame.mixer.music.play(loops=0)
# Create Playlist Box
song_box = Listbox(root, bg='black', fg='green', width=60, selectbackground='gray', selectforeground='black')
song_box.pack(pady=20)
# Define Player Control Buttons
back_btn_img = PhotoImage(file='d:/images/backward.png')
forward_btn_img = PhotoImage(file='d:/images/forward.png')
play_btn_img_ = PhotoImage(file='d:/images/play.png')
pause_btn_img = PhotoImage(file='d:/images/pause.png')
stop_btn_img = PhotoImage(file='d:/images/stop.png')
# Create Player Control Frame
controls_frame = Frame(root)
controls_frame.pack()
# Create Player Control Buttons
back_btn = Button(controls_frame, image=back_btn_img, borderwidth=0)
forward_btn = Button(controls_frame, image=forward_btn_img, borderwidth=0)
play_btn = Button(controls_frame, image=play_btn_img_, borderwidth=0, command=play)
pause_btn = Button(controls_frame, image=pause_btn_img, borderwidth=0)
stop_btn = Button(controls_frame, image=stop_btn_img, borderwidth=0)
back_btn.grid(row=0, column=0, padx=10)
forward_btn.grid(row=0, column=1, padx=10)
play_btn.grid(row=0, column=2, padx=10)
pause_btn.grid(row=0, column=3, padx=10)
stop_btn.grid(row=0, column=4, padx=10)
# Create Menu
my_menu = Menu(root)
root.config(menu=my_menu)
# Add Add Song Menu
add_song_menu = Menu(my_menu)
my_menu.add_cascade(label='Add Songs', menu=add_song_menu)
add_song_menu.add_command(label='Add One Song to Playlist', command=add_song)
root.mainloop()
22:07
for some weird reason i can't creatr image buttons it gives me a error. Someone Help???
what is the error?
You teach very well, thanks!
Thanks!
plz can u tell me how can I add mp3 file of any folder
I have videos on that in the playlist
Prometo que veré su contenido, que versión de python utiliza maestro?
Which language ?
I just use the latest version...it doesn't really matter.
portuguese
@@spyler1565 hablo español
Awesome. Thank you.
You're welcome!
Loved the Video ❤❤
Glad you liked it!
Sir love from Canada
Thanks!
@@Codemycom I am having a error....while pygame.mixer.load(song)
Pygame is not able to load the songs.
And hence the song is not playing
Great Tutorial! Can you make a video on making a mindmap / automatically generate a mindmap from given data. I've been stuck with this problem for a while
Doubtful, I don't use mindmaps...
Is there a way to switch between frames?
Sure. But what do you mean. Switch how?
Codemy.com I would like to have a home screen and different pages. I’ve seen tutorials where they’ve used raise_frame but it looked kinda confusing. Thanks
great work buddy
Thanks!
waw this is so cool and simple
Glad you like it!
My pygame showing error couldn't open file
what did you do differently from the video?
@@Codemycom no same video
nothing different expect the path
@@rishabhdwivedi3748 That's not likely...you have a typo somewhere probably...
@PROPLAYER007 Give it a day or two and check again...you'll see the typo then.
I don't know how to replace C:\ path to a path in Mac! :-( All possibilities fail! Anybody with a Mac found the solution?
Just replace it with the directory structure of your Mac. try /Users/robbery if your home folder is robbery etc.
Very helpful tnx
Most welcome
I'm getting "pygame.error: Unrecognized audio format"
Are you not using mp3 song files?
@@Codemycom I'm using mp3 files
@@johnnyandres7103 Your program doesn't think you are...
Hey, had the same problem. After some searching, the only thing that I could figure out from others was that pygame can no longer run mp3 files for licensing issues. Instead, just use .ogg files. Works just as well, no issues so far.
@@bioethan1 No, that's not the case
ily dude
:-p
Thanks
Welcome!
thanks mr white
Ha, sure thing
I'm having a problem getting it to play,
Check your code for errors
Hey john, plz can u give any suggestions to my programming channel...
Just do what interests you...
@@Codemycom Thanks
im not being able to install pygame on python 3
Why not?
its still updated?!
What is still updated?
@@Codemycom world
23:47
17:00
Nice video!!!
I have a problem: pygame.error: Failed loading libmpg123-0.dll:
I already restarted my computer.
Thank you.
How you resolved this error?? Can you tell me please!
👍
:-)
Sir how to make video player
Sorry, I don't have any videos on that
@@Codemycom can you tell what code in it should be there.
Dúvida Gabriel 16:40
Fantastic!!!!
Many thanks!
Smash the Like button python fans! Doesn't cost you a thing. Great Python tkinter tutorial! cheers!
Much appreciated!