Python Forum
Pygame mixer and tkinter music player - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Pygame mixer and tkinter music player (/thread-26800.html)



Pygame mixer and tkinter music player - Kumarkv - May-14-2020

Hi,

I want to implement music player in tkinter gui. For some reasons I am not able to use python musicplayer library which needs vc++ environment. So I am using pygame mixer module. Stuck on implementation of music players's seek feature.

The following code implemented in pygame mixer and tkinter can play only ogg formats. How to update so as to play mp3 and wav formats also.

https://stackoverflow.com/questions/54081159/how-do-i-link-an-mp3-file-with-a-slider-so-that-the-slider-moves-in-relation-to.

When I try to play MP3 the slider works fine for some times but after the music gets stopped playing. The below method is where the problem occurs.

def UpdateSlider( self, value ):
        '''Move slider position when tk.Scale's trough is clicked or when slider is clicked.'''
        print( '\ndef UpdateSlider():' );       print(type(value),'value = ',value,' sec')
        if self.player.music.get_busy():
            print("Track Playing")
            self.after_cancel( self.loopID ) #Cancel PlayTrack loop    
            self.slider_value.set( value )   #Move slider to new position
            self.Play( )                     #Play track from new postion
        else:
            print("Track Not Playing")
            self.slider_value.set( value )   #Move slider to new position



RE: Pygame mixer and tkinter music player - Larz60+ - May-14-2020

see: https://pypi.org/search/?q=mp3+wav+player&o=-zscore
you'll have to find one from this list that best fits your needs