Skip to content

Issues with playing song in another thread and then pausing it in the main thread #11

@cow0075

Description

@cow0075

Hello
I am trying to have a song play in the background of my app and then pause it whenever I need to. I am probably doing something wrong.
Simplified simulation of what I am trying to achieve:

from audioplayer import AudioPlayer
import threading
import time

a = AudioPlayer(r"D:\songs\bee.mp3")

def test():
    a.play() # 'block=True' here doesn't help with the .pause or .resume issues.

b = threading.Thread(target=test) # Creating a thread
b.start() # This successfully starts the song

time.sleep(10)
print("pausing") # Prints out after 10s
a.pause() # Doesn't affect it at all

time.sleep(10)
print("resuming")# Prints out after another 10s and the program ends

a.resume() # The song just ends here, .resume once again has no effect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions