一台设备一般只有一个声卡,因此在一台设备上多路放音可以按照以下方法:
1、禁用声卡:调用函数:set_null_snd_dev()
2、然后就可以用play file模式模拟通话,具体代码如下:
import sys
import wave
import pjsua as pj
import thread
import _pjsua
from time import sleep
............................
# calculate wav time
wfile = wave.open("jason.wav")
time1 = (1.0 * wfile.getnframes ()) / wfile.getframerate ()
print str(time1) + "ms"
wfile.close()
# stream wav file
current_call.answer(200)
time.sleep(1)
player_id = lib.create_player("jason.wav",True)#True表示循环播放
lib.conf_connect(lib.player_get_slot(player_id),call.info().conf_slot)
lib.conf_connect(call.info().conf_slot,lib.player_get_slot(player_id))
time.sleep(CallDuration)
lib.conf_disconnect(lib.player_get_slot(player_id),call.info().conf_slot)
lib.conf_disconnect(call.info().conf_slot,lib.player_get_slot(player_id))
lib.player_destroy(player_id)
call.hangup()
...........................
该文属于原创,转载该文章,请注明出处,谢谢!