Millicast gives you the ability to utilize advanced features/settings that enable you to broadcast either an Audio-only or Video-only stream. This is great for a variety of use cases, including Radio broadcasting and Security camera feeds to name a couple.
If you’re not already familiar with publishing and viewing your streams with Millicast’s API, it is highly recommended that you read our “How to Broadcast” tutorial.
Audio-only Publisher:
To publish an audio-only stream, the MediaStreamConstraints, video track property must be disabled.
To disabled video the MediaStreamConstraints, video track property should resemble the following:
let mediaStreamConstraints = {
audio: true,
video: false,
};
navigator.mediaDevices.getUserMedia(mediaStreamConstraints)
.then((stream) => { …
Audio-only Viewer:
When subscribing to an audio-only stream, the inbound stream must be attached to an audio element.
let audio = document.createElement(‘audio’);
audio.srcObject = inboundStream; …
Audio-only Publisher and Viewer:
The RTCPeerConnectionOptions on both the publisher and viewer should resemble the following:
let options = {
offerToReceiveAudio: true,
offerToReceiveVideo: false
}
let offer = pc.createOffer(options)
.then(() => { …
Video-only Publisher:
Video-only is also supported by Millicast.
When publishing a video-only stream, the MediaStreamConstraints, audio track property must be disabled.
To disabled audio set the MediaStreamConstraints, audio track property, to the following:
let constraints = {
audio: false,
video: true,
};
navigator.mediaDevices.getUserMedia(constraints)
.then((stream) => {…
Video-only Viewer:
To view a video-only stream, the inbound stream must be attached to a video element.
let audio = document.createElement(‘video’);
audio.srcObject = inboundStream; …
Video-only Publisher and Viewer:
The RTCPeerConnectionOptions on both the publisher and viewer should resemble the following:
let options = {
offerToReceiveAudio: false,
offerToReceiveVideo: true
}
let offer = pc.createOffer(options)
.then(() => { …
To recap, first disable the media type (audio/video) you wish to omit from the MediaStreamConstraints, then make sure the offers created by each peer contains the corresponding RTCOfferOptions, and finally make sure the viewer is attaching the inbound stream to the associated HTML element (audio/video).
We hope this tutorial will help you use Millicast for many interesting use cases. Please comment with any feedback or suggestions. Thank you and enjoy!
-Team Millicast