Video Pre-Caching

A better video experience

As of version 7.2.0 of the Fyber SDK, rewarded videos are preloaded when the SDK starts and played from the cache instead of being streamed. As a result rewarded videos should play right away, thereby improving the overall user experience. To include this feature, add the following service declaration in your AndroidManifest.xml file:

<service android:name="com.fyber.cache.CacheVideoDownloadService" android:exported="false"/>

Precaching makes videos play faster but also uses more bandwidth. Since you might need to use this bandwidth to download some content when your application launches, we provide an API that allows you to pause and resume the rewarded videos precaching.

Pausing a Download

To pause the downloads, add the required import and call the static method pauseDownloads by passing the context as a parameter:

import com.fyber.cache.CacheManager;


Resuming a Download

Once you have downloaded some content and paused it, you can resume the download by adding the following line:


Cache Download Callback

In order to be notified when dowloads are finished OnVideoCachedListener needs to be extended and registered to any context by using the CacheManager.registerOnVideoCachedListener() method.

public class MyVideoCacheCallback extends OnVideoCachedListener {

	public void onVideoCached(boolean videosAvailable) {// "videosAvailable" is true if there is any video cached.

// in your Activity or any Context to register
CacheManager.registerOnVideoCachedListener(myVideoCacheCallback, context);

//for unregistering
CacheManager.unregisterOnVideoCachedListener(myVideoCacheCallback, context);

Warning: Don’t forget to unregister the callback. Best practices encourage using the Destroy() method for unregistering.

To Check for Cached Videos

Simply call CacheManager.hasCachedVideos() and it will return true if there is at least one video downloaded.