Skip to main content

Autoplay

Some browsers allow autoplay with audio; some allow autoplay without audio, while some do not allow autoplay at all.

Audio is, by default, blocked from automatically playing on most mobile devices and some desktop devices. There are, however, cases where an earlier interaction with the web page might be enough to allow auto-playing audio.

Video is generally only blocked if users have manually configured it so (not common) or by more advanced data-saver features on mobile devices (also not common).

Vindral Web SDK will try to autoplay. If it does not succeed, an event will be emitted.

// This event is emitted when the Vindral instance detects that the browser requires a user-initiated click event to start the audio
instance.on("needs user input", () => (button.style.display = "block"))

As the event name implies, an actual user input (e.g., a real user click event) is needed to activate. Showing a unmute/play button is a reasonable course of action.

Muted

In some cases, it might be desirable to start a stream muted. When instantiating Vindral, setting muted: true will ensure no unwanted audio is played.

Video-only autoplay

As previously mentioned, the "needs user input" event can also be triggered for video-only, even if it is not very common.

Setting Volume

Setting volume programmatically does not have consistent behavior between browsers. Therefore it is always recommended to set the volume via user input.

Native

For native integration, autoplay can be achieved by setting the correct options on the WebView instance. Read more about native integration for Android and native integration for iOS.

Further reading

This autoplay guide over at Mozilla is a good place to read more about the subject.