Jamen
Jamen

Reputation: 199

Html Video Tag Cannot load local path

I have a React App running as a WebView inside an iOS app. When I require the files from the iOS app, the app will return the files with the their local paths in the iOS device.

The data looks like

file: {
  thumbnail: "file:///var/mobile/C......png",
  path: "file:///var/mobile/C......mp4",
}

And in the React app, I then use the paths and the html video tag to play the video.

<video poster={file.thumbnail}>
  <source src={file.path} type="video/mp4" />
</video>

And the result is that the poster can be successfully loaded, but the video file itself cannot be.

my question is, if there's some problems with the url being a local path, then the poster should also fail. So why it's only the video source that fails? Is it because I missed something? Or is it because the poster and the source is handled differently behind the scene so that it's only the source that fails?

Upvotes: 0

Views: 289

Answers (1)

Jam3sHalliday
Jam3sHalliday

Reputation: 31

You can move video and images file into your project and save them in assets. I think it will make it easier, and the "path" will not be long like that, readable. Just my opinion.

Upvotes: 1

Related Questions