Feb-05-2021, 01:33 AM
I have been trying to figure this out for a while, and can't find a solution to why it won't work. I'm pretty new, and this is probably an easy fix, but this code:
from tkinter import * import pygame import os import random root = Tk() root.title('Hello') root.geometry('500x400') pygame.init() pygame.mixer.init() randomfile = random.choice(os.listdir("D:/Desktop/Plugin")) def play(): pygame.mixer.music.load(randomfile) pygame.mixer.music.play(loop=0) startButton = Button(root, text="Start", font=("Helvetica", 32), command=play) startButton.pack(pady=20) def stop(): pygame.mixer.music.stop() stopButton = Button(root, text="Stop", command=stop) stopButton.pack(pady=20) root.mainloop()Will always give me the error: pygame.error: Couldn't open 'audio2.mp3' I have 3 audio files in the folder and can't figure out why this wouldnt work.