Using react-native-video to read the video from android asset folder - android

I am using react-native-video to play videos and it works well in React Native asset system. But in my case, I must to read the video from android asset folder.
Does anyone can help me?
Below are the paths I've tried, but unfortunately none of them work.
source={{ uri: 'file:///android_asset/test.mp4' }}
source={{ uri: 'asset:/test.mp4' }}
Related References:
Using file path in react-native-video
Path of Android asset folder
The same issue but he fix it by adjusting source code
Read the video from android raw folder but not my case

Related

React Native Android cannot load html file from local

I would like to load a local html file in my React Native App. Its works in IOS but failed in Android. Here I my code:-
<WebView
originWhitelist={['*']}
source={Platform.OS === 'android' ? { uri: 'file:///android_asset/index.html' } : require('../screens/index.html')}
startInLoadingState={true}
/>
Here is my local html file path.
I have no idea where should I configure in order to get it works...Please help. Thank you.
Code is working. Remember to restart your react server everytime you change in android folder

External HTML asset not bundled by React Native in production build for use by Webview

I'm building an Android application using React Native. It has a webview that reads an HTML file locally.
This is the piece of code I'm using to render webview.
<WebView ref="webview"
source={require('./helloworld.html')}
javaScriptEnabled style={styles.webView} />
This works well during development build. The HTML file loads on the webview and renders well.
But it doesn't on Android release/production build. The webview is empty and if I inspect using chrome://inspect, the webview is empty and doesn't load the HTML file.
From what I understand is the React Native fails to bundle helloworld.html as an asset during Android production build. I noticed that it works fine on iOS.
Any idea how to fix it?
As per the discussions around here https://github.com/facebook/react-native/issues/6004, it's a known defect. Assets are not bundled for Android production build but works fine in dev build.
A solution is store assets in Android assets folder manually, and then load the resource using
<WebView
source={{ uri: 'file:///android_asset/helloworld.html' }}
startInLoadingState={true} />
on RN 0.40,
require('./file.html')
is failing for me in Build release variant. It's fine in debug builds.
As workaround, I was able to put the file in android assets dir, and
{ uri: file:///android_asset/file.html }
load from there. Unfortunately for my situation, the html file loads remote third-party libs which internally reference protocol-agnostic resources: e.g., //domain.com/file.json. So those all got turned into file://domain.com/file.json links and of course failed.
I monkey patched XMLHttpRequest to change //... to https://... which solved that problem, but none of the images those libs attempt to load, will load. all broken. And I've been unable to find a way to determine what the requests look like for those images, to see why they break/fail-to-load.
on iOS production build this solution is work
<WebView
source={{ uri: 'helloworld.html' }}
startInLoadingState={true} />

React native, Unable to resolve module for static image

I'm using react-native 0.14.1
react-native run-android
[3:10:56 PM] <START> find dependencies
Unable to resolve module image!ic_action_android_back_white3 from /Users/lion/Desktop/Developer/AwesomeProject/NewTrackActivity.js
Unable to resolve module image!ic_action_android_back_white3 from /Users/lion/Desktop/Developer/AwesomeProject/NewTrackActivity.js
If I force open my app in Genymotion it can't find my image.
Requiring unknown module image!ic_action_android_back_white3
I'm tried to move image to both ./android/app/src/main/res/drawable-xxx and ./assets/drawable-xxx but neither work.
Have you tried to mount the image, like the new asset manager allows you to do? It's described in the documentation.
Use the following prop for the Image component. Choose the right relative path and dont forget the extension.
<Image source={require('./my-icon.png')} />
Sometimes, your image might include an #2x or #3x for different screen dpi as mentioned in docs. In such case the path should specify the image name without the #2x or #3x suffix. For example if image file name is img#2x.png:
<Image source={require('./img.png')} />
Restart your react packager. That worked for me.
I think this is an issue of adding assets after your initial build.
I closed the emulator and bundler, cleared cache and ran RN - run-ios/run-andriod - and then not a problem.
I was also wondering if just running link might work, but did not get to test this.
You can save your image in that folder itself instead of saving in asset folder and give path as :
<Image source={require('../download.png')} />
It worked for me
I had the same error message Unable to resolve module for files with upper case characters.
My solution - rename file names to lower case.
Using in code:
<Image source={require('../download.png')} />
Versions:
react native - 0.62
expo - 38

Corona SDK: system.pathForFile returns nil

This code works in the simulator but not on my Android device:
local path = system.pathForFile("chinese_rules.db")
print("PATH:: " .. tostring( path ) )
When I run this code on my Galaxy S4 path returns nil.
My first thought was that it was some typo (case sensitivity) but I can't find any typo:
http://i59.tinypic.com/wlpu14.png
I can't find any reason why it should receive nil. This causes a problem as I can't load my database.
I have also tried this with the same result:
local path = system.pathForFile("chinese_rules.db", system.ResourceDirectory)
I have been able to load a path and load databases like this before.
Corona Build: 2013.2100 (2013.12.7)
Further reading the documentation I don't see that .db is a restricted file type:
Corona allows direct loading of images and audio files using the
appropriate APIs, but it has limited access to resource files on
Android using the file I/O APIs. Specifically, the following types can
not be read from the resources directory: .html, .htm., .3gp, .m4v,
.mp4,.png, .jpg, and .ttf.
http://docs.coronalabs.com/api/library/system/pathForFile.html
I found out the reason for the problem:
We are two that are working on this project and he had setup to use expansion files so two files was created (the main APK and the OBB expansion file) which I didn't notice and I only loaded the main APK file and I guess the database is in the OBB file. After setting not to use an expansion file the app works.
usesExpansionFile = false

Open pdf in Android Mobile using IBM Worklight studio

I need to open a pdf in android mobile device.
For that ,I have add a 'test.pdf' pdf file in common folder and add plugin (Childbrowser ) in config.xml file (res/xml/config.xml). And again add childbrowser.js and cordova.js file in js folder .
And add a code to open a pdf file here---
window.open('./test.pdf','_system','location=yes');
But still exception is coming like that 'Target file is not available' andgive a path
file.///data/data/
I want to load that test.pdf file in the android mobile and open that particular file .
But it is not opening .
Please suggest me a solution. Thanks
Unfortunately, Android does not support viewing PDFs out of the box in a WebView. Most results point to using Google Docs.
Here are some suggestions:
Open PDF in a WebView
How to open local pdf file in webview in android?
http://developer.appcelerator.com/question/147570/open-remote-pdf-file-on-webview-in-android
This you could do by combining a Cordova plug-in and this native code: http://kylewbanks.com/blog/Loading-PDF-in-Android-WebView
http://asmncl.blogspot.co.il/2012/06/android-open-pdf-file-in-webview.html

Categories

Resources