-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use HTTP range requests (responses) to serve mp4 from assets #8219
Conversation
By analyzing the blame information on this pull request, we identified @frantic and @martinbigio to be potential reviewers. |
relates to TheWidlarzGroup/react-native-video#246 |
4c64464
to
9a4bb8c
Compare
f946ed8
to
1281024
Compare
updated to current master |
1281024
to
172da92
Compare
rebased to current master |
@@ -168,6 +169,8 @@ const dependencyOpts = declareOpts({ | |||
}, | |||
}); | |||
|
|||
const isRangeRequest = (req) => req.headers && req.headers.range; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not inline it?
Great stuff, thank you! I have a question and a request:
|
@frantic thanks for your valuable feedback! I checked some npm packages but didn't find anything that is small enough to fit into React Native's anyway: I added a test and refactored the range serving to a small function which I named |
58d7895
to
5d540fa
Compare
Looks good, thank you! |
@facebook-github-bot import |
1 similar comment
@facebook-github-bot import |
Thanks for importing. If you are an FB employee go to Phabricator to review. |
91ff686
Summary: #8219 adds range requests to the asset server, but there was an off-by-one-error that made responses end prematurely. This made (for example) react-native-video not work for video assets. This change fixes the off-by-one error and react-native-video works with assets. **Test plan (required)** Try the test in the original pull request for range requests: #8219 Closes #9254 Differential Revision: D3680070 fbshipit-source-id: 3f2a18ba9f35b45b340f4a1046bc099b8444eb7d
Summary: facebook#8219 adds range requests to the asset server, but there was an off-by-one-error that made responses end prematurely. This made (for example) react-native-video not work for video assets. This change fixes the off-by-one error and react-native-video works with assets. **Test plan (required)** Try the test in the original pull request for range requests: facebook#8219 Closes facebook#9254 Differential Revision: D3680070 fbshipit-source-id: 3f2a18ba9f35b45b340f4a1046bc099b8444eb7d
Summary: facebook#8219 adds range requests to the asset server, but there was an off-by-one-error that made responses end prematurely. This made (for example) react-native-video not work for video assets. This change fixes the off-by-one error and react-native-video works with assets. **Test plan (required)** Try the test in the original pull request for range requests: facebook#8219 Closes facebook#9254 Differential Revision: D3680070 fbshipit-source-id: 3f2a18ba9f35b45b340f4a1046bc099b8444eb7d
Summary: This PR solves a problem when video assets are used from third-party React Native components (e.g. [react-native-video](https://github.com/brentvatne/react-native-video). The video will not work while the assets are served from the react native packager because the used video component (iOS) relies on HTTP range requests. I added a small fix that allows ranged requests (e.g. mp4) to be served in ranges. To test this: 1. make new react native project 1. add [react-native-video](https://github.com/brentvatne/react-native-video) to xcode project 1. add video component to your project ``` import Video from 'react-native-video'; var resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSource'); /* ... /* render() { let source = resolveAssetSource(require('./someVideoFile.mp4')) || {}; return <Video /*....*/ source={source} />; } ``` That should not work (if video is smaller than a few megabytes, open app a few times). Then add my fix, that should do the trick. Closes facebook#8219 Reviewed By: davidaurelio Differential Revision: D3542485 Pulled By: frantic fbshipit-source-id: e4f2e4d3aaafa8445e965259bf04ad107dba8a4f
Summary: This PR solves a problem when video assets are used from third-party React Native components (e.g. [react-native-video](https://github.com/brentvatne/react-native-video). The video will not work while the assets are served from the react native packager because the used video component (iOS) relies on HTTP range requests. I added a small fix that allows ranged requests (e.g. mp4) to be served in ranges. To test this: 1. make new react native project 1. add [react-native-video](https://github.com/brentvatne/react-native-video) to xcode project 1. add video component to your project ``` import Video from 'react-native-video'; var resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSource'); /* ... /* render() { let source = resolveAssetSource(require('./someVideoFile.mp4')) || {}; return <Video /*....*/ source={source} />; } ``` That should not work (if video is smaller than a few megabytes, open app a few times). Then add my fix, that should do the trick. Closes facebook#8219 Reviewed By: davidaurelio Differential Revision: D3542485 Pulled By: frantic fbshipit-source-id: e4f2e4d3aaafa8445e965259bf04ad107dba8a4f
Summary: facebook#8219 adds range requests to the asset server, but there was an off-by-one-error that made responses end prematurely. This made (for example) react-native-video not work for video assets. This change fixes the off-by-one error and react-native-video works with assets. **Test plan (required)** Try the test in the original pull request for range requests: facebook#8219 Closes facebook#9254 Differential Revision: D3680070 fbshipit-source-id: 3f2a18ba9f35b45b340f4a1046bc099b8444eb7d
Summary: This PR solves a problem when video assets are used from third-party React Native components (e.g. [react-native-video](https://github.com/brentvatne/react-native-video). The video will not work while the assets are served from the react native packager because the used video component (iOS) relies on HTTP range requests. I added a small fix that allows ranged requests (e.g. mp4) to be served in ranges. To test this: 1. make new react native project 1. add [react-native-video](https://github.com/brentvatne/react-native-video) to xcode project 1. add video component to your project ``` import Video from 'react-native-video'; var resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSource'); /* ... /* render() { let source = resolveAssetSource(require('./someVideoFile.mp4')) || {}; return <Video /*....*/ source={source} />; } ``` That should not work (if video is smaller than a few megabytes, open app a few times). Then add my fix, that should do the trick. Closes facebook/react-native#8219 Reviewed By: davidaurelio Differential Revision: D3542485 Pulled By: frantic fbshipit-source-id: e4f2e4d3aaafa8445e965259bf04ad107dba8a4f
Summary: facebook/react-native#8219 adds range requests to the asset server, but there was an off-by-one-error that made responses end prematurely. This made (for example) react-native-video not work for video assets. This change fixes the off-by-one error and react-native-video works with assets. **Test plan (required)** Try the test in the original pull request for range requests: facebook/react-native#8219 Closes facebook/react-native#9254 Differential Revision: D3680070 fbshipit-source-id: 3f2a18ba9f35b45b340f4a1046bc099b8444eb7d
Summary: This PR solves a problem when video assets are used from third-party React Native components (e.g. [react-native-video](https://github.com/brentvatne/react-native-video). The video will not work while the assets are served from the react native packager because the used video component (iOS) relies on HTTP range requests. I added a small fix that allows ranged requests (e.g. mp4) to be served in ranges. To test this: 1. make new react native project 1. add [react-native-video](https://github.com/brentvatne/react-native-video) to xcode project 1. add video component to your project ``` import Video from 'react-native-video'; var resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSource'); /* ... /* render() { let source = resolveAssetSource(require('./someVideoFile.mp4')) || {}; return <Video /*....*/ source={source} />; } ``` That should not work (if video is smaller than a few megabytes, open app a few times). Then add my fix, that should do the trick. Closes facebook/react-native#8219 Reviewed By: davidaurelio Differential Revision: D3542485 Pulled By: frantic fbshipit-source-id: e4f2e4d3aaafa8445e965259bf04ad107dba8a4f
This PR solves a problem when video assets are used from third-party React Native components (e.g. react-native-video. The video will not work while the assets are served from the react native packager because the used video component (iOS) relies on HTTP range requests.
I added a small fix that allows ranged requests (e.g. mp4) to be served in ranges.
To test this:
That should not work (if video is smaller than a few megabytes, open app a few times). Then add my fix, that should do the trick.