You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

react-native-video-cache-control

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-video-cache-control

react native video cache control

1.2.0
Source
npmnpm
Version published
Weekly downloads
1K
0.98%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-video-cache-control

Reference https://github.com/zhigang1992/react-native-video-cache

Boost performance on online video loading and caching

Use following libraries to do the heavy lifting.

Getting started

$ yarn add react-native-video-cache-control

Install on android

Edit your android/build.gradle file and add the following lines:

maven {
    url "$rootDir/../node_modules/react-native-video-cache-control/android/libs"
}

to your allprojects/repositories

Usage

Normal

// synchronous
import convertToProxyURL from 'react-native-video-cache-control';
...
<Video source={{uri: convertToProxyURL({url: originalURL})}} />
// async
import { convertAsync } from 'react-native-video-cache-control';
...
const [proxyURL, setProxyURL] = useState();
const getProxyURL = async () => {
    try {
        const url = await convertAsync({url: originalURL});
        setProxyURL(url);
    } catch (error) {
        console.log(error);
    }
}

<Video source={{uri: proxyURL}} />

Use Header

import convertToProxyURL from 'react-native-video-cache-control';
...
<Video source={{uri: convertToProxyURL({url: originalURL, headers: {referer: 'https://example.com'}})}} />

Is Cached

import { isCached } from 'react-native-video-cache-control';
...

const bool = isCached({
    url: 'https://prod-streaming-video-msn-com.akamaized.net/a8c412fa-f696-4ff2-9c76-e8ed9cdffe0f/604a87fc-e7bc-463e-8d56-cde7e661d690.mp4',
    headers: {
        referer: 'https://example.com',
    },
})

Delete All Cache

import { clearCache } from 'react-native-video-cache-control';
...
const clearAllCache = async () => {
    try {
        await clearCache();
    } catch (error) {
        console.log(error);
    }
}

Delete Single Cache

import { clearCache } from 'react-native-video-cache-control';
...
const clearSingleCache = async () => {
    try {
        await clearCache('https://prod-streaming-video-msn-com.akamaized.net/a8c412fa-f696-4ff2-9c76-e8ed9cdffe0f/604a87fc-e7bc-463e-8d56-cde7e661d690.mp4');
    } catch (error) {
        console.log(error);
    }
}

Keywords

react-native

FAQs

Package last updated on 24 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.