Build An MP3 Player With Tkinter pt1 - Python Tkinter GUI Tutorial #87

Поделиться
HTML-код
  • Опубликовано: 17 окт 2024

Комментарии • 195

  • @Codemycom
    @Codemycom  4 года назад +8

    ▶️ 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

  • @iniyan19
    @iniyan19 4 года назад +26

    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 .

    • @afk-Legacy
      @afk-Legacy 3 года назад +2

      Thank You! This is what I was looking for.

    • @tarunkumarnagelli9001
      @tarunkumarnagelli9001 3 года назад

      Thank you

    • @mrtrader3661
      @mrtrader3661 3 года назад

      if you use it this way how to get the file path when needed to play a song?

    • @tarunkumarnagelli9001
      @tarunkumarnagelli9001 3 года назад

      @@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)

    • @jensen_9393
      @jensen_9393 3 года назад

      rgwe

  • @MA-UTUBE-99
    @MA-UTUBE-99 4 года назад +2

    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 ***

  • @farhanfaisal6620
    @farhanfaisal6620 4 года назад +4

    Another great tutorial! I really Love your teaching style! Love from Bahrain ❤️❤️

    • @Codemycom
      @Codemycom  4 года назад +2

      Thanks!

    • @MedTech1
      @MedTech1 3 года назад

      nice another Arabic country is learning programming from morocco

  • @Digital963
    @Digital963 3 года назад +1

    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

  • @MathewGracie
    @MathewGracie 4 года назад +3

    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
      @Codemycom  4 года назад +3

      Glad it helped!

    • @MathewGracie
      @MathewGracie 4 года назад

      @@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

    • @MathewGracie
      @MathewGracie 4 года назад

      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

  • @chrisbishop8586
    @chrisbishop8586 2 года назад +1

    How do you code the playlist and play button so that your music choice isn't limited to a specific directory?

  • @pietrodante6016
    @pietrodante6016 Месяц назад

    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.

  • @yusufozan3792
    @yusufozan3792 2 года назад

    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?

    • @Codemycom
      @Codemycom  2 года назад +1

      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.

  • @lasindukashmira7272
    @lasindukashmira7272 4 года назад +1

    Thank you very much sir.
    your tutorials are very easy to Undestand.
    You are perfect.

    • @Codemycom
      @Codemycom  4 года назад

      So nice of you, thanks!

  • @deejay1604
    @deejay1604 2 года назад

    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?

  • @syedhyder5630
    @syedhyder5630 4 года назад +1

    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....!

  • @KUSHANTECHTELUGU
    @KUSHANTECHTELUGU 3 года назад

    I don't know how to install pygame and compiler. Is there any video of yours explaining this..?

    • @Codemycom
      @Codemycom  3 года назад

      pip install pygame from the terminal

  • @3vedinishit
    @3vedinishit 2 года назад

    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

  • @minh145bvn
    @minh145bvn 2 года назад

    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'

    • @Codemycom
      @Codemycom  2 года назад +1

      Did you forget to pip install pygame?

  • @swastiksarkar
    @swastiksarkar 4 года назад

    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??😢😢😢😢

    • @Codemycom
      @Codemycom  4 года назад

      Restart your computer

  • @TechKeda
    @TechKeda 2 года назад

    Whenever i add images/back50.png even i have done it right it says couldn't open it : no such file or directory found

    • @Codemycom
      @Codemycom  2 года назад

      Do you have that image, sitting in that directory?

  • @kennethcallewaert4074
    @kennethcallewaert4074 3 года назад +1

    pygame.error: mpg123_seek: Invalid RVA mode. (code 12) i'm getting this error. Looking forward for help :)

    • @Codemycom
      @Codemycom  3 года назад

      you'll have to google that error

  • @adityachalla7677
    @adityachalla7677 2 года назад

    I am getting an RVA error whenever I try to play the song. Any suggestions???

    • @Codemycom
      @Codemycom  2 года назад

      Google the exact error

  • @rodrigoczleo
    @rodrigoczleo 4 года назад +4

    Amazing! Thank you very much and congrats for the whole knowledge..

    • @Codemycom
      @Codemycom  4 года назад +2

      Glad you liked it!

    • @abeltibebu2524
      @abeltibebu2524 3 года назад

      How can i add function that search music from the playlist?

  • @sarvanisah2746
    @sarvanisah2746 3 года назад

    Failed loading libmpg123-0.dll: The specified module could not be found. How to resolve this error....?

  • @DjSonEntertainment
    @DjSonEntertainment 3 года назад

    Please which app are you using for the music player?

    • @Codemycom
      @Codemycom  3 года назад

      We care building the app

  • @firmanramadhana814
    @firmanramadhana814 2 года назад

    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

    • @Codemycom
      @Codemycom  2 года назад

      You'll have to google the error

    • @xxdrexx2199
      @xxdrexx2199 2 года назад

      Same thing happens to me

  • @AdiMehaindroo
    @AdiMehaindroo 3 года назад

    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

  • @varunjain526
    @varunjain526 3 года назад +1

    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 :)

    • @Codemycom
      @Codemycom  3 года назад +1

      No, you don't need to know that in order to use them.

  • @marcioandre6469
    @marcioandre6469 3 года назад

    i am using visual studio and can not import pygame and it returns that is not recognized as internal or external comand

    • @marcioandre6469
      @marcioandre6469 3 года назад

      someone can help me with that

    • @Codemycom
      @Codemycom  3 года назад +1

      @@marcioandre6469 Yeah, don't use visual studio

  • @danadasachan7208
    @danadasachan7208 Год назад

    thank you so much.. GREAT TUTORIAL!!!

  • @user-oq8nv7xk8x
    @user-oq8nv7xk8x 4 года назад +4

    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 :)

    • @Codemycom
      @Codemycom  4 года назад +5

      May do something like that in the future

  • @chamilgamage9781
    @chamilgamage9781 4 года назад

    Great work walter white im learning a lot from you

  • @Edelity
    @Edelity 2 года назад

    sir i want to ask about how to fix the pygame.error: mpg123_seek: Invalid RVA mode.

    • @Codemycom
      @Codemycom  2 года назад

      no clue, you'll have to google the error

    • @Edelity
      @Edelity 2 года назад

      @@Codemycom thx sir

    • @Edelity
      @Edelity 2 года назад

      actually the song is corrupted sir

    • @Codemycom
      @Codemycom  2 года назад

      @@Edelity Ah, there you go then.

  • @mukeshpandit3958
    @mukeshpandit3958 3 года назад +1

    Excellent tutorial. I wish I could get the source code as you have provided in other tutorials.

    • @Codemycom
      @Codemycom  3 года назад

      It's in the pinned comment of every video.

    • @mukeshpandit3958
      @mukeshpandit3958 3 года назад

      thank you so much for help. have a great day!

  • @RyanDanielG
    @RyanDanielG 3 года назад

    Smash the Like button python fans! Doesn't cost you a thing. Great Python tkinter tutorial! cheers!

  • @siddhantv1
    @siddhantv1 3 года назад

    Great Tutorial! one question,
    can you explain how can i add an image as a background instead of colors in the song box?

    • @TheHyperCrew07
      @TheHyperCrew07 3 года назад +1

      just replace colour with the photo image
      or try out background="image or path"
      this might help

  • @thepalpableleprosyofpollut404
    @thepalpableleprosyofpollut404 3 года назад

    Thank I'm learning a lot from your videos

  • @keshavswami8296
    @keshavswami8296 3 года назад

    Can you please explain how can we add shuffle option in this?

    • @Codemycom
      @Codemycom  3 года назад

      You'd need to create a random number and use it to play that particular song

  • @CodePy
    @CodePy 4 года назад +1

    Thank you very much I hope you will continue with python

  • @PyWolf
    @PyWolf 4 года назад +2

    This Is very cool !! 😎
    Thank you ! 🥇

  • @farzadmohseni7615
    @farzadmohseni7615 3 года назад

    Has the source code of this course not been published in Github ?

  • @BasKuchKarnaH
    @BasKuchKarnaH 3 года назад

    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
      @Codemycom  3 года назад

      Did you try googling the error?

    • @BasKuchKarnaH
      @BasKuchKarnaH 3 года назад

      Yes but i didn't found any solution

    • @BasKuchKarnaH
      @BasKuchKarnaH 3 года назад

      I tried all the alternative provided to solve this but its saying "couldn't open ABC.mp3"

    • @Codemycom
      @Codemycom  3 года назад

      @@BasKuchKarnaH Is that an actual mp3 file? (Not a wav file or something else?) is it actually sitting in that directory?

  • @abolfazlkhojasteh6867
    @abolfazlkhojasteh6867 3 года назад

    The Best tutorial👍👍👍👍👍

  • @nemithafernando5756
    @nemithafernando5756 3 года назад

    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

    • @Codemycom
      @Codemycom  3 года назад

      Then your code isn't exactly like mine. Do you have the images sitting on your computer?

    • @nemithafernando5756
      @nemithafernando5756 3 года назад

      @@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

    • @nemithafernando5756
      @nemithafernando5756 3 года назад

      @@Codemycom Did you Get an answer?

    • @Codemycom
      @Codemycom  3 года назад +1

      @@nemithafernando5756 I didn't read your code. You'll have to do that yourself.

  • @08-huyhungtran38
    @08-huyhungtran38 2 года назад

    Thanks a lot for your tutorial !

  • @priyanshusaxena7157
    @priyanshusaxena7157 4 года назад

    Just one word, Amazing!!!!

  • @EcleCticuS4000
    @EcleCticuS4000 3 года назад

    sry guys, I am getting "Everyrhing", except what is "root" and why we put it everywhere?

    • @Codemycom
      @Codemycom  3 года назад

      root is the name of the app

  • @parvezrahaman7919
    @parvezrahaman7919 3 года назад

    here's an error (import tkinter import filedialog) ,,,, please give a solution.

    • @Codemycom
      @Codemycom  3 года назад

      you imported filedialog incorrectly. Do it exactly as I do it in the video.

  • @karlhabaradas168
    @karlhabaradas168 4 года назад

    Sir I am having this error, can u help me
    pygame.error: Couldn't open 'D:/Music/

    • @karlhabaradas168
      @karlhabaradas168 4 года назад

      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()

    • @karlhabaradas168
      @karlhabaradas168 4 года назад +1

      22:07

  • @sharkzosu70
    @sharkzosu70 3 года назад

    for some weird reason i can't creatr image buttons it gives me a error. Someone Help???

  • @iluvsyphonfilter
    @iluvsyphonfilter 4 года назад

    You teach very well, thanks!

  • @tarunkumarnagelli9001
    @tarunkumarnagelli9001 3 года назад

    plz can u tell me how can I add mp3 file of any folder

    • @Codemycom
      @Codemycom  3 года назад

      I have videos on that in the playlist

  • @brayancastro9234
    @brayancastro9234 4 года назад

    Prometo que veré su contenido, que versión de python utiliza maestro?

    • @spyler1565
      @spyler1565 4 года назад

      Which language ?

    • @Codemycom
      @Codemycom  4 года назад +2

      I just use the latest version...it doesn't really matter.

    • @Codemycom
      @Codemycom  4 года назад

      portuguese

    • @brayancastro9234
      @brayancastro9234 4 года назад

      @@spyler1565 hablo español

  • @dennisearle
    @dennisearle 3 года назад

    Awesome. Thank you.

  • @anujshany8659
    @anujshany8659 4 года назад

    Loved the Video ❤❤

  • @krishharishkumar2923
    @krishharishkumar2923 4 года назад

    Sir love from Canada

    • @Codemycom
      @Codemycom  4 года назад

      Thanks!

    • @rubyekar5112
      @rubyekar5112 4 года назад +1

      @@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

  • @tahanasar8620
    @tahanasar8620 4 года назад

    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

    • @Codemycom
      @Codemycom  4 года назад

      Doubtful, I don't use mindmaps...

  • @jacobfabb
    @jacobfabb 4 года назад

    Is there a way to switch between frames?

    • @Codemycom
      @Codemycom  4 года назад

      Sure. But what do you mean. Switch how?

    • @jacobfabb
      @jacobfabb 4 года назад

      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

  • @ritikrao1782
    @ritikrao1782 4 года назад

    great work buddy

  • @DJPRINCEDaniel
    @DJPRINCEDaniel 2 года назад

    waw this is so cool and simple

  • @rishabhdwivedi3748
    @rishabhdwivedi3748 3 года назад +1

    My pygame showing error couldn't open file

    • @Codemycom
      @Codemycom  3 года назад +1

      what did you do differently from the video?

    • @rishabhdwivedi3748
      @rishabhdwivedi3748 3 года назад

      @@Codemycom no same video

    • @rishabhdwivedi3748
      @rishabhdwivedi3748 3 года назад

      nothing different expect the path

    • @Codemycom
      @Codemycom  3 года назад

      @@rishabhdwivedi3748 That's not likely...you have a typo somewhere probably...

    • @Codemycom
      @Codemycom  3 года назад

      @PROPLAYER007 Give it a day or two and check again...you'll see the typo then.

  • @robbery30
    @robbery30 2 года назад

    I don't know how to replace C:\ path to a path in Mac! :-( All possibilities fail! Anybody with a Mac found the solution?

    • @Codemycom
      @Codemycom  2 года назад

      Just replace it with the directory structure of your Mac. try /Users/robbery if your home folder is robbery etc.

  • @abeltibebu2524
    @abeltibebu2524 3 года назад

    Very helpful tnx

  • @johnnyandres7103
    @johnnyandres7103 3 года назад

    I'm getting "pygame.error: Unrecognized audio format"

    • @Codemycom
      @Codemycom  3 года назад

      Are you not using mp3 song files?

    • @johnnyandres7103
      @johnnyandres7103 3 года назад

      @@Codemycom I'm using mp3 files

    • @Codemycom
      @Codemycom  3 года назад +1

      @@johnnyandres7103 Your program doesn't think you are...

    • @bioethan1
      @bioethan1 3 года назад +1

      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.

    • @Codemycom
      @Codemycom  3 года назад

      @@bioethan1 No, that's not the case

  • @Acem8887
    @Acem8887 2 года назад

    ily dude

  • @codewithahmed9806
    @codewithahmed9806 4 года назад +1

    Thanks

  • @orkhanahmadov9963
    @orkhanahmadov9963 2 года назад

    thanks mr white

  • @shanecromer8085
    @shanecromer8085 2 года назад

    I'm having a problem getting it to play,

    • @Codemycom
      @Codemycom  2 года назад

      Check your code for errors

  • @spyler1565
    @spyler1565 4 года назад

    Hey john, plz can u give any suggestions to my programming channel...

    • @Codemycom
      @Codemycom  4 года назад

      Just do what interests you...

    • @spyler1565
      @spyler1565 4 года назад

      @@Codemycom Thanks

  • @RAGEEcs
    @RAGEEcs 4 года назад

    im not being able to install pygame on python 3

  • @cringium
    @cringium 4 года назад

    its still updated?!

    • @Codemycom
      @Codemycom  4 года назад

      What is still updated?

    • @gorge9774
      @gorge9774 4 года назад

      @@Codemycom world

  • @bobsagget823
    @bobsagget823 2 года назад

    23:47
    17:00

  • @hemetgamelab
    @hemetgamelab 3 года назад +1

    Nice video!!!
    I have a problem: pygame.error: Failed loading libmpg123-0.dll:
    I already restarted my computer.
    Thank you.

    • @sarvanisah2746
      @sarvanisah2746 3 года назад

      How you resolved this error?? Can you tell me please!

  • @gamedev3036
    @gamedev3036 3 года назад

    👍

  • @rohndahemsworth9604
    @rohndahemsworth9604 3 года назад

    Sir how to make video player

    • @Codemycom
      @Codemycom  3 года назад

      Sorry, I don't have any videos on that

    • @rohndahemsworth9604
      @rohndahemsworth9604 3 года назад

      @@Codemycom can you tell what code in it should be there.

  • @advance2
    @advance2 3 года назад

    Dúvida Gabriel 16:40

  • @kapibara2440
    @kapibara2440 3 месяца назад

    Fantastic!!!!

  • @RyanDanielG
    @RyanDanielG 3 года назад

    Smash the Like button python fans! Doesn't cost you a thing. Great Python tkinter tutorial! cheers!