MP3 Player Forward and Back Buttons pt3 - Python Tkinter GUI Tutorial #89

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

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

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

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

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

    I already added those buttons this morning...
    And i also added a progress bar which indicates the duration of the current playing song but i failed to add scrolling system with the progressing bar
    #Lol you are a true teacher
    #lots of love from india

  • @akramelomrani8728
    @akramelomrani8728 3 года назад +6

    Its crazy how these tutorials are amazing

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

      Glad you think so!

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

      from tkinter import *
      from pygame import mixer
      import os
      from tkinter.filedialog import askopenfile
      def backsong():
      songstatus.set('back')
      mixer.music.back()
      def playsong():
      currentsong = songList.get(ACTIVE)
      print(currentsong)
      mixer.music.load(currentsong)
      songstatus.set('Playing')
      mixer.music.play()
      def stopsong():
      songstatus.set('Stopped')
      mixer.music.stop()
      #create global pause
      global paused
      paused = False
      def pausesong(is_paused):
      global paused
      paused = (is_paused)
      if paused:
      mixer.music.unpause()
      paused = False
      else:
      mixer.music.pause()
      paused = True
      def nextsong():
      nextone = songList.curselection()
      nextone = nextone[0]+1
      song = songList.get(nextone)
      mixer.music.load(song)
      mixer.music.play()
      def open_file():
      songs = askopenfile(initialdir='C://', mode ='r', filetypes =[('mp3 files', '*.mp3')], title='Please select a')
      #add song to list box
      songList.insert(END,songs)
      window = Tk()
      # main window geometry
      window.geometry('450x300')
      # main window title
      window.title('O MUSIC PLAYER')
      window.resizable(TRUE,TRUE)
      mixer.init()
      songstatus=StringVar()
      songstatus.set('Choosing')
      #create a listbox of songs to select from
      songList=Listbox(window, width =35)
      songList.grid(row=0,column=0,padx=10)
      #scroll = Scrollbar(songList)
      #scroll.pack(side=RIGHT, fill=Y)
      #scroll.config( command = songList.yview )
      os.chdir(r'C:\\Users\\OLIS\\Music\\Burna Boy - Twice As Tall - (SongsLover.com)')
      songs=os.listdir()
      for song in songs:
      if song.endswith('.mp3'):
      songList.insert(END,song)
      #create music player images button
      backBtn_img=PhotoImage(file='C:\\Users\\OLIS\\Desktop\\HELLO CODE\Music Player\\151845-music-player-icons\\png\\back.png')
      playBtn_img=PhotoImage(file='C:\\Users\\OLIS\\Desktop\\HELLO CODE\\Music Player\\151845-music-player-icons\\png\\play.png')
      pauseBtn_img=PhotoImage(file='C:\\Users\\OLIS\Desktop\\HELLO CODE\\Music Player\\151845-music-player-icons\\png\\pause.png')
      stopBtn_img=PhotoImage(file='C:\\Users\\OLIS\\Desktop\\HELLO CODE\\Music Player\\151845-music-player-icons\\png\\stop.png')
      nextBtn_img=PhotoImage(file='C:\\Users\\OLIS\\Desktop\\HELLO CODE\\Music Player\\151845-music-player-icons\\png\
      ext.png')
      #create track frame
      trackFrame = Frame(window)
      trackFrame.grid(row=0,column=1, sticky=S, padx=10)
      #create control buttons
      backBtn = Button(trackFrame, image=backBtn_img, borderwidth=0, command=backsong)
      playBtn = Button(trackFrame, image=playBtn_img, borderwidth=0, command=playsong)
      pauseBtn = Button(trackFrame, image=pauseBtn_img,borderwidth=0, command= lambda:pausesong(paused))
      stopBtn = Button(trackFrame, image=stopBtn_img, borderwidth=0, command=stopsong)
      nextBtn = Button(trackFrame, image=nextBtn_img, borderwidth=0, command=nextsong)
      playBtn.grid(row=0, column=2,padx=5)
      pauseBtn.grid(row=0, column=1,padx=5)
      stopBtn.grid(row=0, column=3,padx=5)
      nextBtn.grid(row=0, column=4,padx=5)
      backBtn.grid(row=0, column=0,padx=5)
      addfile=Label(window,text='Select music from folder :')
      addfile.grid(row=1,column=0,padx=10,sticky=W)
      #add file control
      addfileBtn_img = PhotoImage(file='C:\\Users\\OLIS\\Desktop\\HELLO CODE\Music Player\\151845-music-player-icons\\png\\addfile.png')
      #create add file button
      addfileBtn = Button(window, image=addfileBtn_img, borderwidth=0, command = lambda:open_file())
      #addfile to window
      addfileBtn.grid(row=2,column=0,padx=10,sticky=W)
      window.mainloop()

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

      ive made several mistakes and i don't know where to start

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

      @@olisfortune6326 Do you want to see my code ?

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

    Best Tkinter playlist!

  • @swastiksarkar
    @swastiksarkar 3 года назад +2

    Tell me something. Imagine the selected song is the one at the end of the listbox. When i press the next button I want the first song in the song to be selected. How do I do that?

  • @jaytayade3309
    @jaytayade3309 3 года назад +2

    when I run the project I get this error: next_one = next_one[x] + 1
    IndexError: tuple index out of range can you help me out with this error?

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

    Msny thanks for your inspiring work!

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

      Glad you're enjoying it!

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

    If i select many songs then i want that after one song finished play then automaticly must go to the next song and play and so on.
    How to code that?
    Please need your help!!

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

    Hello John,
    I'm sorry that my question is not specifically related to the topic of your video, i was just trying to reach you
    I'm wondering if it's possible to keep on using the default sqlite3 database rather than postgresql/mongoDb/mysql with django project (My senior project)
    My project is kind of E-commerce application with functionality to the user to register/login/add to cart/view cart items/checkout etc..
    Admin can CRUD products and customers from the admin home page
    all i want is to perform certain actions on product or customer from my admin home page and see it directly saved and refreshed in the table in db Browser for sqlite
    And in general can sqlite3 make the same actions as postgresql/ Mongodb...

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

      Sure, it just depends on the web host (some won't let you use sqlite3 because it's not suited for heavy use). Though, the beauty of using a web framework like Django is that you can swap out any database without needing to change the database code at all. Just change your settings.py file to designate whatever database you want to use. Your app code (your models.py file for instance) doesn't change at all. So it's sort of irrelevant...

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

      @@Codemycom So helpful Thank you Sir I appreciate your time ❤

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

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

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

    when I run the project I get this error: next_one = next_one[x] + 1
    IndexError: tuple index out of range
    and I do everything good I copy your code and its steal doing this I use pycharm you can help me?

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

      Sorry, I never use pycharm

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

      because you didn't choose item in list box. Put this code to add_song and add_many_song function and it will be fine
      song_box.select_set(0)

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

      @@_toilatung Thanks

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

    seriously bro, please and please i'll seriously need the ebook for this tkinter and cant wait for you to write that book.This just so much to grab at ones... Thanks a lot for all the videos

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

      Will be writing it :-)

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

    song is frist one when I clicked the backward but the song is not restart ..still continue.. could u please explain sir....

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

      Check your code for typos

  • @EdinDestanovic-uv1ph
    @EdinDestanovic-uv1ph 2 года назад

    Wonderful tutorial :)

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

    Hi John,
    my curselection() didnt print tuple as yours like (0, ) or (1, 0).
    my ide print out is
    ()
    ()
    ()
    next_one = next_one[0]+1
    IndexError: tuple index out of range

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

      what ide?

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

      because you didn't choose item in list box. Put this code to add_song and add_many_song function and it will be fine
      song_box.select_set(0)

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

    If i hit the fwd button, the selection does go ahead one... but every time after that, the fwd button just restarts the current song. Also, getting 'tuple out of range'.

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

      Damn.... had this...song_box.selection_set(next_one, last=None).... with "_____" around None..... excuse me while I slap myself.

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

    Hello bro, I have a problem
    File "D"\Developer\Test\1.py, line 68, in previous_song
    song = f' D:/Developer/Complete/Song/{song}.mp3'
    UnboundLocalError: local variable 'song' referenced before assignment
    my line 68 : song = f'D:/Developer/Complete/Song/{song}.mp3'

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

      your song variable is being referenced before it gets assigned..

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

      @@Codemycom Can you say clearer

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

      @@ekitran Your code is not the same as the video. The structure is wrong. Your variable is being called in the program before you have defined it in the program.

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

      @@Codemycom Oh my code has a problem.Sorry to bother you, thank you very much.

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

    I found 1 exception while clicking forward or back button. If it is the end of list or beginning of the list we cannot go forward or back becuase the index of the list becuase not accessible!
    Hopefully the following code might fix you the error if you too got the same.
    #In def next_song():
    #Before song = song_box.get(next_one)
    Size = song_box.size()
    If next_one == size:
    Next_one = next_one - size
    #In previous_song():
    Size=song_box.size()
    If next_one == -1
    Next_one = next_one + size

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

    Hey if i sign up for a course on codemy will i get a certificate for it ?

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

      Yeah you get a certificate with course completion.

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

    Thanks

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

    I keep getting this error whenever i try to execute the program
    _tkinter.TclError: unknown option "-lable"
    Please Help

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

      You've misspelled label as lable somewhere

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

      @@Codemycom oh thankyou

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

    'tuple' object is not callable [0] +1... I need help please

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

      check your code for typos

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

    like the image on the buttons, im nicking that idea :)

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

    I have a problem with forwarding button i write the code as you write it but its not working

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

      You likely have a typo

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

      @@Codemycom pygame.mixer.music.load(sound)
      NameError: name 'sound' is not defined this is my eror

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

      @@MedTech1 it’s telling you that you haven’t set the variable named sound.

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

      @@Codemycom oh ya thanks just i write sond not sound sorry

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

    great can you do the same with pls files or both with mp3. thanks.

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

      I don’t know what pls files are

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

    thank you

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

    😳 ooooh my GOD, amazing

  • @LifterAndy
    @LifterAndy Год назад +1

    lesson is very good. it's just that I'm an asshole