Open lsy0314 opened 6 years ago
Googling:
Solution1:
$ sudo apt install pulseaudio
$ pulseaudio --kill; pulseaudio --start
Solution2:
# wait for 2 seconds after play audio file.
time.sleep(2)
Solution3:
Solution4: (RECOMMENDED)
# play audo file: -ao alsa , -ao pluse
# cmd = "mplayer -ao pulse " + search_path + audio_file
# mplayer is not good. It results in "Audio device got stuck!" error.
cmd = "cvlc " + search_path + audio_file + " vlc://quit"
print "[DEBUG] Succeeded, command: %s." % cmd
print "[DEBUG] We found audio file."
print "[DEBUG] Let's play the audio file:" , cmd
os.system(cmd)
Test result1 with cvlc:
#############################################################################
[DEBUG] Original audio file name (string) is 201807221100_4f0b13cf22c361d44b75ec78976079f9.m4a
[DEBUG] Changed audio file name (string) is 201807221100
[DEBUG] check vaule is True
[DEBUG] Okay. The file name is number.
[DEBUG] Valid. This file is *.m4a audio file.
[DEBUG] check execution number 810
[DEBUG] Changed audio file name (int) is 201807221100
[DEBUG] Starting...
[DEBUG] ---------------------------------
[DEBUG] audio_time 201807221100, current time 201807221100
[DEBUG] ---------------------------------
[DEBUG] Succeeded, command: cvlc ../webapp/audio/201807221100_4f0b13cf22c361d44b75ec78976079f9.m4a vlc://quit.
[DEBUG] We found audio file.
[DEBUG] Let's play the audio file: cvlc ../webapp/audio/201807221100_4f0b13cf22c361d44b75ec78976079f9.m4a vlc://quit
VLC media player 2.2.2 Weatherwax (revision 2.2.2-0-g6259d80)
[01d04c20] dummy interface: using the dummy interface module...
[6b301000] idummy demux: command `quit'
#############################################################################
Test result2 with cvlc:
#############################################################################
[DEBUG] Original audio file name (string) is 201807221550_ff6f2c9498fefc6cd204239be0e752a7.m4a
[DEBUG] Changed audio file name (string) is 201807221550
[DEBUG] check vaule is True
[DEBUG] Okay. The file name is number.
[DEBUG] Valid. This file is *.m4a audio file.
[DEBUG] check execution number 555
[DEBUG] Changed audio file name (int) is 201807221550
[DEBUG] Starting...
[DEBUG] ---------------------------------
[DEBUG] audio_time 201807221550, current time 201807221550
[DEBUG] ---------------------------------
[DEBUG] Succeeded, command: cvlc ../webapp/audio/201807221550_ff6f2c9498fefc6cd204239be0e752a7.m4a vlc://quit.
[DEBUG] We found audio file.
[DEBUG] Let's play the audio file: cvlc ../webapp/audio/201807221550_ff6f2c9498fefc6cd204239be0e752a7.m4a vlc://quit
VLC media player 2.2.2 Weatherwax (revision 2.2.2-0-g6259d80)
[01823c30] core interface error: no suitable interface module
[01771948] core libvlc error: interface "globalhotkeys,none" initialization failed
[01823c98] dbus interface error: Failed to connect to the D-Bus session daemon: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
[01823c98] core interface error: no suitable interface module
[01771948] core libvlc error: interface "dbus,none" initialization failed
[01823c98] dummy interface: using the dummy interface module...