react-native-video: Video doesn't work with new cameraRoll uri path with prefix "ph://" on iOS RN 0.59.5
Current behavior
video playback doesn’t work with RN 0.59.5 with new cameraRoll URI format using prefix “ph://” on iOS
Reproduction steps
get videos from cameraRoll on iOS and use the URI path with prefix “ph://”
Expected behavior
Video should play
Platform
Which player are you experiencing the problem on: iOS
Details: With RN 0.58.6 cameraRoll returned videos in this format for example:
{ node:
{ timestamp: 1515357324,
location:
{ altitude: 0,
heading: -1,
speed: -1 },
group_name: 'Camera Roll',
type: 'ALAssetTypeVideo',
image:
{ width: 720,
height: 1280,
isStored: true,
filename: 'IMG_0013.mp4',
uri: 'assets-library://asset/asset.mp4?id=D34D1148-2CC7-4AE9-BB2E-67ACBCB60A10&ext=mp4',
playableDuration: 10 } } }
Passing the ‘asset-library’ URI to react-native-video v4.4.0 worked.
However in React Native v0.59.x the cameraRoll API returns videos in the format:
node:
{ timestamp: 1554232151,
type: 'video',
group_name: 'Camera Roll',
location: {},
image:
{ width: 1080,
uri: 'ph://D916EEFD-317B-403D-B589-B3ED9B17E784/L0/001',
height: 1920,
isStored: true,
playableDuration: 4.365 } } }
react-native-video does not work with the new URI format.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 7
- Comments: 17 (1 by maintainers)
This is what I did to get it working
This should get it working until
react-native-videoadds a fixConverting assets from PH:// to assets-library:// seems to work if the file is local, but in instances where you fetch ‘All’ from CameraRoll you can at times find a video that is stored on iCloud. Trying to load these videos will not load (onLoad) and does not throw an error (onError).
I’m setting up a timeout to notify users if the file does not load right away (not local file) but has anyone uncovered a way to load iCloud assets into react-native-video?
@talal7860 nice snippet, I use your code and it’s work perfect at Image, but when i preview a video, it gives me an
NSURLDominError with code -1100, whichreact-native-videosay the uri is not exist. and I noticed my video is on my iCloud instead of local. do you have any advice?Long time since last comment, but I just ran into this problem using the camera roll directly.
Not sure I if I feel comfortable relying on all this string wrangling, but basically this works if the filename of the file is predictable:
in use (don’t mind the props in the player, it’s a HoC built for my purposes, the url prop maps directly to the
source={{uri: 'some url'}})prop in the react-native-video component…You need to patch the react-native-video lin, using asset-library uris hacky and was very error-prone. Here is our patch, based on @fishkingsin fork (updated it). With this
ph://uris work flawless regardless of where the asset is saved (local/iCloud):@ramon90 thanks. Does ‘react-native-gallery-manager’ have any other specific advantages over using the default ‘CameraRoll’ API? I’m wondering if we need to add other library in the stack just to make loading and playing video from camera roll work. 😃 It would be good if CameraRoll and ‘react-native-video’ are compatible to each other as both are so fundamental.