diff --git a/README.md b/README.md
index ca5d907..4d63eb3 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,6 @@ Use following libraries to do the heavy lifting.
- iOS: https://github.com/ChangbaDevs/KTVHTTPCache
- Android: https://github.com/danikula/AndroidVideoCache
-
## Getting started
`$ yarn add react-native-video-cache`
@@ -17,10 +16,9 @@ Use following libraries to do the heavy lifting.
`$ react-native link react-native-video-cache`
## Usage
+
```javascript
import convertToProxyURL from 'react-native-video-cache';
...
-const localProxiedURL = await convertToProxyURL(originalURL);
-...
-
+
```
diff --git a/android/src/main/java/com/reactnative/videocache/VideoCacheModule.java b/android/src/main/java/com/reactnative/videocache/VideoCacheModule.java
index fbbfe66..c8e66c4 100644
--- a/android/src/main/java/com/reactnative/videocache/VideoCacheModule.java
+++ b/android/src/main/java/com/reactnative/videocache/VideoCacheModule.java
@@ -21,13 +21,11 @@ public class VideoCacheModule extends ReactContextBaseJavaModule {
return "VideoCache";
}
- @ReactMethod
- public void convert(
- String url,
- Promise promise) {
+ @ReactMethod(isBlockingSynchronousMethod = true)
+ public void convert(String url) {
if (this.proxy == null) {
this.proxy = new HttpProxyCacheServer(this.reactContext);
}
- promise.resolve(this.proxy.getProxyUrl(url));
+ return this.proxy.getProxyUrl(url);
}
}
diff --git a/example/App.js b/example/App.js
index 6bf51bf..bdeac2b 100644
--- a/example/App.js
+++ b/example/App.js
@@ -1,57 +1,36 @@
-/**
- * Sample React Native App
- *
- * adapted from App.js generated by the following command:
- *
- * react-native init example
- *
- * https://github.com/facebook/react-native
- */
+import React, { Component } from "react";
+import { StyleSheet, Text, View } from "react-native";
+import convertToCache from "react-native-video-cache";
-import React, { Component } from 'react';
-import { Platform, StyleSheet, Text, View } from 'react-native';
-import convertToCache from 'react-native-video-cache';
-
-export default class App extends Component<{}> {
- state = {
- status: 'starting',
- message: '--'
- };
- componentDidMount() {
- convertToCache('https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-720p.mp4').then((message) => {
- this.setState({
- status: 'native callback received',
- message
- });
- });
- }
- render() {
- return (
-
- ☆VideoCache example☆
- STATUS: {this.state.status}
- ☆NATIVE CALLBACK MESSAGE☆
- {this.state.message}
-
- );
- }
+export default function App() {
+ const url =
+ "https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-720p.mp4";
+ return (
+
+ ☆Original URL☆
+ {url}
+ ☆Proxy URL for Video Component☆
+ {convertToCache(url)}
+
+ );
}
const styles = StyleSheet.create({
container: {
flex: 1,
- justifyContent: 'center',
- alignItems: 'center',
- backgroundColor: '#F5FCFF',
+ justifyContent: "center",
+ alignItems: "center",
+ backgroundColor: "#F5FCFF",
+ padding: 20
},
welcome: {
fontSize: 20,
- textAlign: 'center',
+ textAlign: "center",
margin: 10,
},
instructions: {
- textAlign: 'center',
- color: '#333333',
+ textAlign: "center",
+ color: "#333333",
marginBottom: 5,
},
});
diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock
index 8bfc08f..98939ea 100644
--- a/example/ios/Podfile.lock
+++ b/example/ios/Podfile.lock
@@ -129,9 +129,9 @@ SPEC CHECKSUMS:
KTVCocoaHTTPServer: df8d7b861e603ff8037e9b2138aca2563a6b768d
KTVHTTPCache: 588c3eb16f6bd1e6fde1e230dabfb7bd4e490a4d
React: 36d0768f9e93be2473b37e7fa64f92c1d5341eef
- react-native-video-cache: a9b3bb7c7ad2c33348a35ed5617ac93cf179c9f9
+ react-native-video-cache: 90b8857673151d2618fc61030f14d755d1e92d4e
yoga: 684513b14b03201579ba3cee20218c9d1298b0cc
PODFILE CHECKSUM: 8cb65c707639127200176815b46fe7b0846ce649
-COCOAPODS: 1.8.4
+COCOAPODS: 1.9.3
diff --git a/ios/VideoCache.m b/ios/VideoCache.m
index 8288aa4..c0417b9 100644
--- a/ios/VideoCache.m
+++ b/ios/VideoCache.m
@@ -1,25 +1,20 @@
#import "VideoCache.h"
#import
-
@implementation VideoCache
RCT_EXPORT_MODULE()
-RCT_EXPORT_METHOD(convert:(NSString *)url
- resolver:(RCTPromiseResolveBlock)resolve
- rejecter:(RCTPromiseRejectBlock)reject)
+RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(convert:(NSString *)url)
{
- if (!KTVHTTPCache.proxyIsRunning) {
- NSError *error;
- [KTVHTTPCache proxyStart:&error];
- if (error) {
- reject(@"init.error", @"failed to start proxy server", error);
- return;
+ if (!KTVHTTPCache.proxyIsRunning) {
+ NSError *error;
+ [KTVHTTPCache proxyStart:&error];
+ if (error) {
+ return url;
+ }
}
- }
- resolve([KTVHTTPCache proxyURLWithOriginalURL:[NSURL URLWithString:url]].absoluteString);
+ return [KTVHTTPCache proxyURLWithOriginalURL:[NSURL URLWithString:url]].absoluteString;
}
-
@end
diff --git a/ios/VideoCache.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/VideoCache.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 0000000..18d9810
--- /dev/null
+++ b/ios/VideoCache.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+