1

I'm new with python. Just trying to create mp3 player. Unfortunatelly have an error:

for event in event.get():

UnboundLocalError: local variable 'event' referenced before assignment

I have no idea how can I fix it.

    song_list_not_empty = Playlist.get(0, END)
    if song_list_not_empty:
        if not paused:
            SONG_END = pygame.USEREVENT + 1
            pygame.mixer.music.set_endevent(SONG_END)
            pygame.mixer.music.load(Playlist.get(ACTIVE))
            current_song_name()
            play_time()
            slider_position = int(song_lenght)
            song_slider.config(to=slider_position, value=0)
            pygame.mixer.music.play(repeat)
            while True:
                for event in event.get():  # <--  here 
                    if event.type == SONG_END:
                        next_song()
                        player.update()      
        else:
            pygame.mixer.music.unpause()
            button1.config(borderwidth=1)
            button3.config(borderwidth=0)
    else:
        tkinter.messagebox.showerror(title="Error", message="No songs on the playlist")```

0 Answers0