My program is playing music with simpleaudio in python. But I would like to use the complexaudio extension that should allow to pause/resume the music. But i can't find any documentation of how to use it in order to do that. I've only been able to install complexaudio, but can't find any example... Is there anybody who already used those functions ? many thanks !!!
Asked
Active
Viewed 642 times
1 Answers
0
I had the same problem as you but solved it :)
So first i uninstalled simpleaudio lib : pip uninstall simpleaudio
Then i installed complexaudio lib : pip install complexaudio
Then i went to have a look in the Site-Packages folder and in shiny.py which is actually simpleaudio script i saw this :
class PlayObject(object):
def __init__(self, play_id):
self.play_id = play_id
def pause(self):
return _sa._pause(self.play_id)
def resume(self):
return _sa._resume(self.play_id)
def stop(self):
_sa._stop(self.play_id)
def wait_done(self):
while self.is_playing():
sleep(0.05)
def is_playing(self):
return _sa._is_playing(self.play_id)
PS : This lib works only for wav files so you can use mp3 to wav online but will make huges wav files :'(
For the use of the complexaudio functions it's really simple :
import simpleaudio as sa
import time
wave_obj = sa.WaveObject.from_wave_file("zik.wav")
play_obj = wave_obj.play()
time.sleep(3)
play_obj.pause()
print("paused")
time.sleep(3)
play_obj.resume()
print("resumed")
time.sleep(3)
play_obj.stop()
print("stoped")
play_obj.wait_done()

Dharman
- 30,962
- 25
- 85
- 135

Garbez François
- 327
- 3
- 13