Hello,
I’m not sure if this is a common issue but for some reason I am unable to publish a stream with only audio. The only time audio works is if the video is also active.
I wish to give control to users to choose whether to publish video only, audio only, or both. Users have a camera icon they press to publish the video and microphone icon they press to publish the audio. When they first click either the video or audio icon the stream is initially published; afterwards, when they press an icon, either the tablePublisher.publishVideo(bool) or tablePublisher.publishAudio(bool) is executed. As described through, the audio is only active when the video is active. It doesn’t seem possible to have only the audio active without video. Any help would be really appreciated! My code is seen below:
changeMuteState = () => {
let {tablePublisher} = this.props.eventData;
if (this.props.eventData.isMuted){
if (tablePublisher === undefined){
this.initialStreamPublish(true, false);
this.props.muteSelf(false);
}
else{
tablePublisher.publishAudio(true);
this.props.muteSelf(false);
}
}
else{
tablePublisher.publishAudio(false)
this.props.muteSelf(true);
}
}
publishSelf = () => {
let {tablePublisher} = this.props.eventData;
if (tablePublisher === undefined){
this.initialStreamPublish(false, true);
this.props.updateVisibility(true);
this.props.muteSelf(false);
}
else{
//tableSession.publish(tablePublisher);
tablePublisher.publishVideo(true);
this.props.updateVisibility(true);
}
}
unpublishSelf = () => {
let { tablePublisher } = this.props.eventData;
if (tablePublisher && tablePublisher.stream){
//tableSession.unpublish(tablePublisher);
tablePublisher.publishVideo(false);
this.props.updateVisibility(false);
}
}
initialStreamPublish = (audioOption, videoOption) => {
let {tableSession, tableConnectionId} = this.props.eventData;
if (tableSession !== undefined || tableConnectionId === ''){
let tablePublisher = this.props.OV.initPublisher(undefined, {
audioSource: undefined, // The source of audio. If undefined default microphone
videoSource: undefined, // The source of video. If undefined default webcam
publishAudio: audioOption, // Whether you want to start publishing with your audio unmuted or not
publishVideo: videoOption, // Whether you want to start publishing with your video enabled or not
resolution: '320x240', // The resolution of your video
frameRate: 30, // The frame rate of your video
insertMode: 'APPEND', // How the video is inserted in the target element 'video-container'
mirror: true, // Whether to mirror your local video or not
});
// --- 6) Publish your stream ---
tableSession.publish(tablePublisher);
// Set the main video in the page to display our webcam and store our Publisher
this.props.setTablePublisher(tablePublisher);
}
}