cheofusi / just_playback

A small library for playing audio files in python, with essential playback functionality.
MIT License
70 stars 7 forks source link

App crash when using specific Windows utilities #25

Open JavideSs opened 1 year ago

JavideSs commented 1 year ago

Hi, I tried just_playback and it worked! But I have a problem integrating it with my app.

When there is an instruction where a specific Windows component is used, it crashes. Can't open tkinter filedialog, application freezes. Also, my module ported from c++ to use the Taskbar Thumbnail Toolbar causes the application to terminate when the ThumbBarSetImageList() function is called.

Working on Windows 10 with Python 3.10.

Example

from just_playback import Playback
from tkinter import filedialog
playback = Playback()
playback.load_file('music-files/sample.mp3')
playback.play()
filedialog.askdirectory(title="Select folder")
cheofusi commented 1 year ago

The sample code runs fine on my Linux machine.

This seems to be a problem with tkinter on Windows as discussed here and here. Try issuing all calls on the Playback object in a separate thread.

JavideSs commented 1 year ago

It isn't an interface freeze error. The tkinter app works fine. Crash when there is a call to a particular windows utility. Maybe a bad interaction with a dll.

Windows 10,11. In linux works fine.

from just_playback import Playback
from tkinter import filedialog
playback = Playback() #removing this initialization the problem disappears
filedialog.askdirectory(title="Select folder") #not shown, crash
print("not executed")

No problem with a new thread. I don't know why it works, but it's not the right way

cheofusi commented 1 year ago

No problem with a new thread. I don't know why it works, but it's not the right way

So it does work in a separate thread? And if it does why do you feel it's not right?

JavideSs commented 1 year ago

It worked with the pygame.mixer module without the need for a new thread. The tkinter app works fine, it even plays songs with just_playback and everything works fine. Except when I use filedialog() or Taskbar Thumbnail Toolbar in Windows. A non-blocking call such as Playback() should not crash specific functions. I can't do ctrl+c to terminate the example program.