According to the documentation, there doesn't seem to be any examples of using external images or external videos (i.e. from YouTube).
I was wondering if anyone knew if it was possible (like this)
<Video style={{
width: 3.0,
height:2.0,
transform: [{translate: [0, 4, 5]}, {rotateY : 180} ],
}} source={{uri: 'https://www.youtube.com/watch?v=vPCoxAlfFsw'}} />
MediaPlayerState in react vr home page
Related
Edited: only don't work in release
I use react native version 0.60.3. Before one year make an application with local images and it works well. I update Xcode to version 11 and old code and images work well also. I try to add new images for dark mode but the image doesn't show, there isn't an error, only blank space.
In code use images from js file like :
"url":require("../images/page1.png").
Images are added to copy bundle resources.
I try with command :
npx react-native bundle --entry-file='index.ios.js' --bundle-output='./ios/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios
and copy assets and main.jsbundle to Xcode and get the same results, before I don't have assets folder in XCode, images are been in copy bundle resources.
Old images work (which are added before one year), new images don't work. Did I miss something? I don't have an error and don't know how to fix this issue.
My code:
<CustomImage
width={getImgWidth} height={getImgHeight}
lightpath={it.url}
darkpath={it.urldark}
darkmode={theme.darkmode} />
CustomImage.js
const CustomImage = (props) => {
return (
<View style={{ width: props.width, height: props.height }}>
{props.darkmode ? (
<Image
resizeMode="contain"
style={{ width: props.width, height: props.height }}
source={props.darkpath}
/>
) : (
<Image
resizeMode="contain"
style={{ width: props.width, height: props.height }}
source={props.lightpath}
/>
)}
</View>
);
};
Since props.darkpath = require("../images/page1.png")
Could you try:
<Image
resizeMode="contain"
style={{ width: props.width, height: props.height }}
source={`${props.darkpath}`}
/>
This may seem like a duplicate but I've followed the answers to maybe a dozen similar questions on Stack and none of the solutions are working for me.
The React Native docs say load to local images like so:
<Image source={require('./my-icon.png')} />
I've placed the image 3D-home2#x.jpg in the same folder as the JS file:
I also tried placing it at the project root:
I also tried placing it in Images.xcassets and loading it like require('image!3D-home').
In between these efforts, I cleared the module cache several times with yarn start -- --reset-cache. Did a full XCode project 'clean' several times and rebuilt the app. No matter what I do I get some variation of this error (project name redacted):
What am I doing wrong here? It seems like I'm following the instructions exactly but I cannot get an image to load.
<Image
style={{
position: 'absolute',
width: '100%',
height: '100%',
top: 0,
left: 0,
zIndex: 10
}}
source={ require('./3D-home#2x.jpg') }
/>
The solution was to remove #2x from the file name. This is because React Native offers the ability to automatically swap out images using suffixes, so I was unwittingly trying to do that incorrectly or something:
You can also use the #2x and #3x suffixes to provide images for
different screen densities.
https://facebook.github.io/react-native/docs/images.html
Images with spaces in their name won't load in IOS, for android it worked by replacing the spaces with %20, but this solution didn't work on ios. React native.
I m loading the images remotely using uri, in a normal Image container. images without space load fine.
<Image source={{uri: fileName.replace(/ /g, '%20')}} style={styles.image} />
works on react-native#0.59.5
encodeURI("http://www.yourdomain.tld/sample image.jpg")
Output
http://www.yourdomain.tld/sample image.jpg
to
http://www.yourdomain.tld/sample%20image.jpg
Usage
<Image source={{uri: encodeURI(fileUri)}} />
the best way is to use the js builtin javascript function encodeURI
because we also have to convert some special characters in URLs
I am trying to reuse some components built for web application using reactjswith radium.
I have a component which contains outline css property . I reuse the component , unfortunalty , i got this error :
My questions are :
What is the alternative of outline property in react-native for both ios or android ?
Is there alternative of radium in react-native ?
Should I manage manually this difference of style properties naming among iOs DEV, android DEV as well as web DEV ?
I think you are looking for the border styles.
More specifically from the facebook react native docs:
borderWidth ReactPropTypes.number
borderStyle ReactPropTypes.oneOf(['solid', 'dotted', 'dashed'])
So for instance if you wanted to make a 10 x 10 box with dashed lines...
<View style={{ borderWidth:1, borderStyle: 'dashed', width: 10, height: 10, }} />
Hi im looking at intergrating fancybox with a youtube video but I want it so when you visit a website it pops up and automaticly plays without clicking a link.
for example. if you visit http://www.turkspoultry.com/ i want a video to suddenly popup and start playing about the history of turks poultry.
any ideas?
I was trying to figure out the same thing earlier, and I ended up ditching youtube. As far as I know, there is no way to autostart youtube videos, I could be wrong.
What I did is I loaded the video into EasyHTML5Video and it spat out 4 different video files and an index.html, I then put that index in a sub folder and I called the video/page in fancy box using:
$(document).ready(function () {
$.fancybox({
'width': 745,
'height': 565,
'autoScale': false,
'transitionIn': 'fade',
'transitionOut': 'fade',
'type': 'iframe',
'href': 'Mylinktothehtmlpage'
});
});
That auto opens the page and as long as you check mark AutoPlay when you are in EasyHTML5Video then all should work!