初始化时
// init engine
mRtcEngine = IRtcEngine.GetEngine(appId);
if (mRtcEngine == null)
return;
mRtcEngine.SetChannelProfile(CHANNEL_PROFILE.CHANNEL_PROFILE_GAME);
mRtcEngine.SetClientRole(CLIENT_ROLE.BROADCASTER);
// set callbacks (optional)
mRtcEngine.OnJoinChannelSuccess = onJoinChannelSuccess;
mRtcEngine.OnUserJoined = onUserJoined;
mRtcEngine.OnUserOffline = onUserOffline;
mRtcEngine.EnableWebSdkInteroperability(true);
mRtcEngine.OnRemoteVideoStateChanged = OnRemoteVideoStateChangedHandler;
mRtcEngine.DisableAudio();
mRtcEngine.EnableAudioVolumeIndication(500, 3, true);
mRtcEngine.EnableVideo();
mRtcEngine.EnableVideoObserver();
mRtcEngine.EnableLocalVideo(false);
mRtcEngine.SetDefaultAudioRouteToSpeakerphone(true);
mRtcEngine.AdjustRecordingSignalVolume(0);]
mRtcEngine.SetLogFilter(LOG_FILTER.DEBUG | LOG_FILTER.INFO | LOG_FILTER.WARNING | LOG_FILTER.ERROR |
LOG_FILTER.CRITICAL);
我打电话mRtcEngine.SetDefaultAudioRouteToSpeakerphone(true(;
在我调用JoinChannel((之后
mRtcEngine.JoinChannel(channel, null, 0);
if (mRtcEngine.EnableVideoObserver() == Decimal.Zero)
{
mRtcEngine.EnableVideoObserver();
}
mRtcEngine.EnableAudio();
mRtcEngine.SetEnableSpeakerphone(true);
我呼叫setEnableSpeakerphone(真(
但它仍然从扬声器中传出(好像是一个电话(,我是不是错过了一步?
第一组代码对我来说似乎还可以。但我认为应该将第二组代码放入回调处理程序中
// implement engine callbacks
private void onJoinChannelSuccess(string channelName, uint uid, int elapsed)
{
// mRtcEngine.EnableVideoObserver(); // you've called this!
mRtcEngine.EnableAudio();
mRtcEngine.SetEnableSpeakerphone(true);
}
我在iPhone上试了一下代码,它是从扬声器里传出来的。请注意,您可能希望使用演示应用程序作为发送方应用程序来测试这一点,而不是这个重写的代码。
从切换
mRtcEngine.SetChannelProfile(CHANNEL_PROFILE.CHANNEL_PROFILE_GAME);
至
mRtcEngine.SetChannelProfile(CHANNEL_PROFILE.CHANNEL_PROFILE_COMMUNICATION);
成功了。文档中有一条注释,游戏配置文件不允许更改扬声器。