Skip to content
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

Feature/ios drm support #5

Open
wants to merge 325 commits into
base: master
Choose a base branch
from
Open

Conversation

danielmarino24i
Copy link

@danielmarino24i danielmarino24i commented Jan 22, 2019

ISSUE: https://jira.24i.com/browse/PRJ001NXG-82

WIP PR to start adding feedback provided.

Example integration:

<VideoPlayer
                    ref={(ref) => {
                        this.player = ref;
                    }}
                    source={{
                        uri: 'https://edge.pureflix-static-hls.top.comcast.net/eSalt_Media/51/35/-urlsig=O0U9MTU0ODE2NDEyNTtBPTE7Sz0xO1A9MDExMDtTPTk2NWJhMmVkYmIzY2MwMTM3YzMwMjViOGE4MWQ0M2MzY2I1NzcwMzg/1269215299797-1530642225256-master.m3u8',
                        drm: {
                            type: 'fairplay',
                            contentId: 'slaKjktHQxp_',
                            certificateUrl: 'http://pmd205533tn-a.akamaihd.net/eSalt_Media/609/915/fairplay.cer',
                            licenseServer: 'https://fairplay.entitlement.theplatform.com/fpls/web/FairPlay?token=tTzzsJim7CA8kr7ycesWwaD68HAg4LBM&schema=1.0&form=json&account=http://access.auth.theplatform.com/data/Account/2446140407',
                            headers: {
                                'X-AxDRM-Message': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ2ZXJzaW9uIjoxLCJjb21fa2V5X2lkIjoiYjMzNjRlYjUtNTFmNi00YWUzLThjOTgtMzNjZWQ1ZTMxYzc4IiwibWVzc2FnZSI6eyJ0eXBlIjoiZW50aXRsZW1lbnRfbWVzc2FnZSIsImZpcnN0X3BsYXlfZXhwaXJhdGlvbiI6NjAsInBsYXlyZWFkeSI6eyJyZWFsX3RpbWVfZXhwaXJhdGlvbiI6dHJ1ZX0sImtleXMiOlt7ImlkIjoiOWViNDA1MGQtZTQ0Yi00ODAyLTkzMmUtMjdkNzUwODNlMjY2IiwiZW5jcnlwdGVkX2tleSI6ImxLM09qSExZVzI0Y3Iya3RSNzRmbnc9PSJ9XX19.FAbIiPxX8BHi9RwfzD7Yn-wugU19ghrkBFKsaCPrZmU'
                            },
                            getLicense: (spcString, props) => {
                                const base64spc = btoa(spcString);
                                return fetch(props.source.drm.licenseServer, {
                                    method: 'POST',
                                    headers: {
                                        'Content-Type': 'application/json',
                                        Accept: 'application/json',
                                    },
                                    body: JSON.stringify({
                                        getFairplayLicense: {
                                            releasePid: props.source.drm.contentId,
                                            spcMessage: base64spc,
                                        }
                                    })
                                })
                                    .then(response => response.json())
                                    .then((response) => {
                                        if (response && response.getFairplayLicenseResponse && response.getFairplayLicenseResponse.ckcResponse) {
                                            return response.getFairplayLicenseResponse.ckcResponse;
                                        }
                                        throw new Error('No correct response');
                                    })
                                    .catch((error) => {
                                        console.error('CKC error', error);
                                    });
                            }
                        }
                    }}
                    useTextureView={false}
                    title={title}
                    testID="videoPlayer"
                    // style={styles.container}
                    videoStyle={styles.backgroundVideo}
                    onBack={onBack}
                    onLoad={({ audioTracks: loadedAudioTracks }) => {
                        if (loadedAudioTracks) {
                            this.setState({
                                audioTracks: loadedAudioTracks.map(loadedAudioTrack => ({
                                    language: loadedAudioTrack.title
                                }))
                            });
                        }
                    }}
                    onError={(error) => {
                        console.error('RNV Error', error);
                    }}
                    selectedAudioTrack={{
                        type: 'title',
                        value: audioTrack
                    }}
                />```

Copy link

@hosek hosek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe change drm type to enum to avoid typo and clearly see what types are supported?

@danielmarino24i
Copy link
Author

@hosek done! thanks

return theData;
}

- (NSString*)base64forData:(NSData*)theData {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function can be avoided there is a native method for that:
https://developer.apple.com/documentation/foundation/nsdata/1417833-init

})).catch((error) => {
NativeModules.VideoManager.setLicenseError(error, findNodeHandle(this._root));
});
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if there's no data or data.spc?

Video.js Outdated
});
}
} else {
NativeModules.VideoManager.setLicenseError("No enough data for license override", findNodeHandle(this._root));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Not enough…" would be a bit better 😁

Video.js Outdated
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed?

[request setValue:value forHTTPHeaderField:key];
}
}
//

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed?

CHANGELOG.md Outdated
@@ -1,5 +1,8 @@
## Changelog

### Version 4.3.1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this a minor update the least?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to next so they can decide

if([httpResponse statusCode] != 200){
NSLog(@"Error getting license from %@, HTTP status code %li", url, (long)[httpResponse statusCode]);
NSError *licenseError = [NSError errorWithDomain: @"RCTVideo"
code: -1337

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add these numbers to an Enum?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactored to error enum

README.md Outdated
@@ -420,15 +420,18 @@ Platforms: iOS
Platforms: iOS

#### headers
Pass headers to the HTTP client. Can be used for authorization.
Pass headers to the HTTP client. Can be used for authorization. Headers must be a part of the source object.

To enable this on iOS, you will need to manually edit RCTVideo.m and uncomment the header code in the playerItemForSource function. This is because the code used a private API and may cause your app to be rejected by the App Store. Use at your own risk.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still the case now?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is coming from an update of RNV itself. It is related with source > headers, not source > drm > headers

Ibrahim Sulaiman and others added 15 commits February 6, 2019 03:22
… true. requestAudioFocus was being run regardless of there being a src, so I made it so that only gets requested when a src exists.
Support for displaying controls in Android Exoplayer
I'm guessing this change was made to cleanup the code, however it is not functionally identical and may cause issues. Revert until those can be discussed.
Feature Implementation: Recovery from transient internet failures
If an undefined source is accidentally loaded in react-native-video a fatal error SIGABRT will happen and crash the application. This is very difficult to debug since there's apparently no relation between this crash and react-native-video. So this change checks if the URI is empty and, if it is, it throws an error, allowing the user to find out early about the issue.

https://cloud.githubusercontent.com/assets/5795227/20283860/08223ba6-aabb-11e6-9fdc-d12d32b3aa9a.png
marlonandrade and others added 2 commits February 26, 2020 20:43
…roup#1931)

this fixes the case on any time you have a react view that displays the video, but it's being rendered with controls but not as a full screen (ie. easily reproducible when you have a tabbar for instance - the reactViewController.view frame shouldnt be the whole screen bounds).
@8ntexerra
Copy link

@sanjeevghimire
I'm completely sure that this isn't a propper way, but passing prop like that worked for me:
@"spcBase64": [NSString stringWithFormat:@"%@", [spcData base64EncodedStringWithOptions:0]]

euharrison and others added 23 commits April 20, 2020 17:25
# Summary

We've been recommending devs use `npx pod-install` since it will attempt to install CocoaPods CLI if it's not available on the computer (cite [React Navigation setup guide](https://reactnavigation.org/docs/getting-started/#installing-dependencies-into-a-bare-react-native-project)). This has proved very useful for Expo users who are now migrating to the bare workflow and want to use community packages in their projects.

## Checklist

- [x] I have tested this on a device and a simulator
- [x] I added the documentation in `README.md`
* added trackId to exoplayer onLoad callback

* added trackInfo to bandwidth callback

* syntax fix

* syntax fix

* version update

* sending complete logcat for media playback exception ExoPlaybackException

* version bump

* package publish changes

* Live playback fix

* Version bump

* import fix

* version bump

* configurable preferredForwardBufferDuration

* configurable preferredForwardBufferDuration

* version update

* Exposing time

* exo player window current tsp

* return type

* Current window timestamp in epoch

* iOS changes

* version update

* Updated package.json

* updated version

* CurrentTime bug fix

* Updated package.json

* Updated currentPlaybackTime

* Updated currentPlayback logic

* Updated package.json

* Bug fix

* Added semicolon

* updated package.json

* Updated ReactVideoView

* updated verison

* Revert package.json changes

* Update ReactVideoView.java

* Use standard log

* Document preferredForwardBufferDuration (iOS)

* Document currentPlaybackTime

* Document trackId

* Update CHANGELOG.md

* Update CHANGELOG.md

* Update README.md

* Update CHANGELOG.md

Co-authored-by: anubansal <[email protected]>
Co-authored-by: Sivakumar J <[email protected]>
Co-authored-by: parikshit <[email protected]>
Co-authored-by: anubansal92 <[email protected]>
Co-authored-by: Rishu Agrawal <[email protected]>
Co-authored-by: rishu-curefit <[email protected]>
…arzGroup#1862)

* update UIInterfaceOrientation in fullscreen

* update code
* Add flag on iOS

* Add flag in Android

* Add documentation

* Add changelog entry

* Also set setKeepScreenOn

* Fix prop not being set

* add preventsDisplaySleepDuringVideoPlayback to exoplayer

* Update android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java

* Update android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java

Co-authored-by: Jens Andersson <[email protected]>

Co-authored-by: Anton Tanderup <[email protected]>
Co-authored-by: Jens Andersson <[email protected]>
…2053)

* Fix exoplayer aspect ratio update on source changes

* Update CHANGELOG.md
alexejh pushed a commit to simpleTechs/react-native-video that referenced this pull request Jul 29, 2022
Add support for customizing back buffer duration and handle network errors gracefully to prevent releasing the player when network is lost.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.