[loadAssetsAsync] Prefetch videos like Image.prefetch

Hi! in my loadAssetsAsync function, I need to prefetch videos too. Videos of my app are really small, but need to be prefetch.

Currently my code looks like this:

loadAssetsAsync = async () => {
    const videos = _.merge(routineVideos); // routineVideos: array of key => require() videos...
    const cacheVideos = _.map(videos, video => {
      if (typeof video === 'string') {
        return Video.prefetch(video); // Does Video.prefetch exists?
      }

      return Asset.fromModule(video).downloadAsync();
    });

    const fonts = [MaterialCommunityIcons.font];
    const cacheFonts = fonts.map(font => Font.loadAsync(font));

    await Promise.all([...cacheVideos, ...cacheFonts]);
  };

Is there something similar to Image.prefetch but for videos?

Thanks!

There is no Video.prefetch but you could try FileSystem.downloadAsync and then playing the video from the local URI.

https://docs.expo.io/versions/latest/sdk/filesystem.html#expofilesystemdownloadasyncuri-fileuri-options

Great! Will try and post the resulting code here for you to check it out.

Thanks!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.