ascoders / react-native-image-viewer

🚀 tiny & fast lib for react native image viewer pan and zoom
MIT License
2.45k stars 580 forks source link

Visualize video inside the viewer #379

Open Gabogg07 opened 4 years ago

Gabogg07 commented 4 years ago

I am trying to display images and videos inside the viewer, but can't figure out how to add the videos. I don't mind if they show at the end, but they been part of the numeric count, and the swipe motion is required.

Thanks

jamesawer3 commented 4 years ago

Any updates regarding this

Gabogg07 commented 4 years ago

@jamesawer3 i couldn't manage to do it with this library, I had to use an slider component and adapt it for the different media types

pashanaumov commented 4 years ago

@Gabogg07 , could be too late, but worth asking. What are you using to display the video? I am using a react-native-video component inside the renderImage function. Wrapping video inside a <View> with flex: 1 does the job for me

gerryfletch commented 4 years ago

@pavelnaumov Are you able to share more specifically what you used to get video to work? Perhaps it's due to a difference in version, but there are some weird styles on the parent container such that flex: 1 on a view in renderImage does not have a set width and height. I haven't looked too much into this library code, but my understanding is that it's likely using the Image API to fix the width + height of the parent container.

gerryfletch commented 4 years ago

For anyone interested, I can confirm that the width + height given to the parent container is proportional to the image size. You can provide the image size if you know it beforehand with the image and width parameters fields of your imageUrls array. Since I did not have an aspect ratio or specific width/height for my videos, I used the dimensions of the window. These are the general steps I took:

Anzormumladze commented 4 years ago
const urls = content.map((c, index) => {
  // check image/video
  return { url, width, height, props: {index} };
});

can you provide code?