Answer the question
In order to leave comments, you need to log in
Audio not playing in tkinter?
from tkinter import *
from tkinter.ttk import *
from tkinter import filedialog as fd
from mutagen.mp3 import MP3
import ntpath
import datetime
import pygame
from pymsgbox import *
def open():
global fileName, org_timeMinutes, org_timeSeconds
filePath = fd.askopenfilename()
fileName = ntpath.basename(filePath)
root.title("Simple Audio Player: Selected: "+fileName)
f = MP3(filePath)
org_timeDuration = datetime.timedelta(seconds=int(f.info.length))
org_timeMinutes = str(int(org_timeDuration.seconds / 60))
org_timeSeconds = str(org_timeDuration.seconds - int(org_timeDuration.seconds / 60) * 60)
print(org_timeMinutes + ":" + org_timeSeconds)
def play():
root.title("Simple Audio Player: Playing: "+fileName)
pygame.init()
pygame.mixer.music.load(filePath)
pygame.mixer.music.play()
root = Tk()
root.title("Simple Audio Player")
root.geometry("600x350")
root.resizable(False, False)
openButton = Button(text="Open", command=open)
openButton.pack()
playButton = Button(text="Play", command=play)
playButton.pack()
root.mainloop()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question