Skip to main content
Version: 4.12.7

Preloading

This article contains a description of the possible preloading settings and will show you how to use them on your player. This is possible on Web, Android and iOS SDKs. The aim of preloading is to improve user experience by loading parts of the video before the Play button is hit when the user is likely to play the video.

At the bottom, you will be able to find interesting Resources on this topic.

SDKs

Web SDKAndroid SDKiOS SDKtvOS SDKAndroid TV SDKChromecast SDK
YesYesYesYesYesN/A

How to use preloading

Choosing to preload your video content will reduce the start-up time of your videos. It will also make some data regarding the current source (video duration, timeline thumbnails, etc.) available before the user initiates playback. On the other hand, when the video is less likely to be played, or when it is less beneficial (live video; autoplay) you can configure the player to not preload it and save bandwidth. Here is how.

Preloading settings

ValueDescription
noneDo not preload anything. After setting the source, the player will not load the manifest nor any media files until the play method is invoked on the player.
metadataPreload the metadata of the video. After setting the source, the player will automatically load the manifest file and will wait for loading media files until the play method is invoked on the player. For static videos (e.g. MP4 files), this translates to preloading data from the start of the video in order to acquire e.g. the video's width and height and the initial video frames.
autoPreload enough data to allow for smooth initial playback. After setting the source, the player will load both the manifest files and enough media files until a sufficient playback buffer has been obtained.

Code examples

Web SDK

In this example, we are preloading metadata only.

player.preload = "metadata";
Android SDK

To activate preload, you need to import the player preloadType:

import com.theoplayer.android.api.player.PreloadType;

You can then choose the option you prefer:

   tpv = new THEOplayerView(this);
...
tpv.getPlayer().setPreload(PreloadType.METADATA, callbackHandler);

Here, callbackHandler is a method to establish which actions are to be taken when preloading has been successfully completed.

iOS/tvOS SDK and Legacy iOS/tvOS SDK (4.12.x)

To use preloading

self.theoplayer?.setPreload(.metadata)

Sample Applications

The demo below illustrates the Preload API in production.

Remarks

Note that THEOplayer will always prefer downloading data for the currently playing video over downloading data for a preloading video. Only when the currently playing video has enough data to play to the end of the video, will the player start preloading other videos.

Resources