Skip to content

Commit

Permalink
Package update - v5.2.1 (#1)
Browse files Browse the repository at this point in the history
* Fix so background audio from other apps can play when disableFocus is true. requestAudioFocus was being run regardless of there being a src, so I made it so that only gets requested when a src exists.

* Added details to readme and changelog

* update for androidX

* change minSdkVersion back to 16

* update readme

* remove duplicate ReactVideoPackage()

* add readme to migrating to AndroidX

* add read me

* fix read me

* pre androidX, upgrade to 28

* remove duplicated line in example

* change dead code in  example

* Remove calls to [super observe] to fix crash

* Add TheWidlarzGroup#1646 to changelog

* bring back super KVO with selector check

* Fix memory leak when using AVPlayerViewController, make sure to release player

* Updated changelog

* changelog for TheWidlarzGroup#1629

* bump version

* chang maven to google

* fix when controls & muted

* update changelog

* handle racing conditions when props are setted on exoplayer

* fix for setControls

* fix repeat

* comment why postDelayed

* remove extra whitespace

* remove rnpm

* 4.4.4

* Update README.md

Make installation parts easier to link

* Update README.md

fix typo

* Update README.md

Make more obvious the changes needed via using diff

* Update MainApplication.java

fix indent

* remove matchingfallbacks in example

* prepare 5.0.0 version

* cpck androidx

* change minSdkVersion back to 16

(cherry picked from commit a96fa33)

* update readme

(cherry picked from commit 3ddcba3)

* add readme to migrating to AndroidX

(cherry picked from commit 976ebcc)

* cpck readme

* fix read me

(cherry picked from commit ed25b3f)

* chang maven to google

(cherry picked from commit 8a8f215)

* cpck

* ad platform installation to TOC

(cherry picked from commit b0737bd)

* More update info

(cherry picked from commit 2f23cc0)

* 5.0.1

* Fixed Exoplayer doesn't work with mute=true TheWidlarzGroup#1696

* Updated README.md to include instructions for React Native 0.60 and above

* Removing the call to observeValueForKeyPath:ofObject:change:context: on super from RCTVideo.
If the super class is not actually observing the key, the app will crash. Checking to see if
the super class responds to this selector doesn't solve this issue.

react-native-video github issue: TheWidlarzGroup#1515

Discussion about this particular problem: https://stackoverflow.com/questions/6574714/whats-wrong-with-this-observevalueforkeypathofobjectchangecontext-implement

* Updated CHANGELOG to reflect bug fix in PR 1720

* added support for automaticallyWaitsToMinimizeStalling property on iOS

* update readme

* fix invert boolean property

* bumped version & updated changelog

* fix formatting issues

* fix formatting
fix crash iOS9

* changelog for TheWidlarzGroup#1696

* Update issue templates

* Update bug_report.md

* Update bug_report.md

* Fix indent and respect previous rate

* Bring the basic example back to a runnable state

* Remove Exoplayer deprecations

- Bump Exoplayer to 2.10.4
- Remove deprecated usages of Exoplayer methdos
- Add `ReactExoplayerConfig` as extension points to configure the Exoplayer instance

* Update changelog with Exoplayer update (TheWidlarzGroup#1766)

* update package json version

* update changelog version

* Add disableFocus to TOC

* fix typo in README

* Clear progress messages on STATE_IDLE and STATE_BUFFERING (TheWidlarzGroup#1768)

The progress message handler will duplicate recursions of the `onProgressMessage` handler on change of player state from any state to STATE_READY with `playWhenReady` is true (when video is not paused). This clears the messages on STATE_IDLE and STATE_BUFFERING to break the recursion.

* fix README about reportBandwidth (TheWidlarzGroup#1816)

* Fixes a situation when exiting fullscreen, where observed keypath values have not been released

* add try catch block around removal of observer keypaths on playerViewController

* Audio Poster issue fix (TheWidlarzGroup#1779)

* Add full screen support to Android Exoplayer (TheWidlarzGroup#1730)

* Bump version to 5.1.0-alpha

* Fix readme grammar (TheWidlarzGroup#1888)

* Improve Android Audio Focus (TheWidlarzGroup#1897)

Implement audio focus as per android docs:
https://developer.android.com/guide/topics/media-apps/audio-focus
https://medium.com/androiddevelopers/audio-focus-3-cdc09da9c122

AUDIOFOCUS_LOSS should abandon focus and not try resuming audio, this is done with AUDIOFOCUS_LOSS_TRANSIENT

This fixes at least:
- Audio not being paused after focus being taken by some voip applications
- Content resuming and pausing instantly sporadically (some race condition perhaps) when activity was resumed from background.

* Update changelog (TheWidlarzGroup#1913)

* docs(video): fix bufferConfig property name (TheWidlarzGroup#1855)

* Fix play/pause regression after added fullscreen support. (TheWidlarzGroup#1916)

* v5.1.0-alpha4

* Bump javascript dependencies (TheWidlarzGroup#1914)

Also update linting rules to match other community repositories.

* Add support for react-native Windows Cpp/WinRT (TheWidlarzGroup#1893)

This also deprecates the old react-native windows implementation

* Fix the `ref` sample code to remove the syntax error

* Update changelog

* v5.1.0-alpha5

* Don't set reactViewController view frame to whole screen (TheWidlarzGroup#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).

* Update onLoad event to include videoTracks info

* add mixWithOthers prop

* Update README.md

* Update index.ios.js

* Fix video dimensions for HLS streams

* Changelog

* Compare CGFloats instead

* Update CHANGELOG.md

* Update CHANGELOG, alpha-6 hasn't been released yet

* Implement pending seek

* Recommend npx pod-install for setup instructions

# 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`

* Expose currentPlaybackTime when live stream video (TheWidlarzGroup#1944)

* 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]>

* [ios] Adaptive fullscreen in landscape by device orientation (TheWidlarzGroup#1862)

* update UIInterfaceOrientation in fullscreen

* update code

* Revert "[ios] Adaptive fullscreen in landscape by device orientation (TheWidlarzGroup#1862)" (TheWidlarzGroup#2043)

This reverts commit c9096d1.

* Upgrade exoplayer to 2.11.4 (TheWidlarzGroup#2034)

* Removed JS fullscreening for Android (TheWidlarzGroup#2013)

* Always set headers for iOS (TheWidlarzGroup#2014)

* Support preventsDisplaySleepDuringVideoPlayback (TheWidlarzGroup#2019)

* 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]>

* Fix exoplayer aspect ratio update on source changes (TheWidlarzGroup#2053)

* Fix exoplayer aspect ratio update on source changes

* Update CHANGELOG.md

* Add iOS and Android basic DRM support (TheWidlarzGroup#1445)

This PR adds support for DRM streams on iOS (Fairplay) and Android (Playready, Widevine, Clearkey)

I am neither Android nor iOS developer, so feel free to provide feedback to improve this PR.

**Test stream for ANDROID:**
```
testStream = {
        uri: 'http://profficialsite.origin.mediaservices.windows.net/c51358ea-9a5e-4322-8951-897d640fdfd7/tearsofsteel_4k.ism/manifest(format=mpd-time-csf)',
        type: 'mpd',
        drm: {
            type: DRMType.PLAYREADY,
            licenseServer: 'http://test.playready.microsoft.com/service/rightsmanager.asmx?cfg=(persist:false,sl:150)'
        }
    };
```

or 
```
{
    uri: 'https://media.axprod.net/TestVectors/v7-MultiDRM-SingleKey/Manifest_1080p.mpd',
    drm: {
        type: 'widevine', //or DRMType.WIDEVINE
        licenseServer: 'https://drm-widevine-licensing.axtest.net/AcquireLicense',
        headers: {
            'X-AxDRM-Message': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ2ZXJzaW9uIjoxLCJjb21fa2V5X2lkIjoiYjMzNjRlYjUtNTFmNi00YWUzLThjOTgtMzNjZWQ1ZTMxYzc4IiwibWVzc2FnZSI6eyJ0eXBlIjoiZW50aXRsZW1lbnRfbWVzc2FnZSIsImZpcnN0X3BsYXlfZXhwaXJhdGlvbiI6NjAsInBsYXlyZWFkeSI6eyJyZWFsX3RpbWVfZXhwaXJhdGlvbiI6dHJ1ZX0sImtleXMiOlt7ImlkIjoiOWViNDA1MGQtZTQ0Yi00ODAyLTkzMmUtMjdkNzUwODNlMjY2IiwiZW5jcnlwdGVkX2tleSI6ImxLM09qSExZVzI0Y3Iya3RSNzRmbnc9PSJ9XX19.FAbIiPxX8BHi9RwfzD7Yn-wugU19ghrkBFKsaCPrZmU'
        },
    }
}
```

**Test stream for iOS:**
Sorry but I can not provide free streams to test. If anyone can provide test streams, or found some we can use, please let me know to also test them.

It has been tested with a private provider and they work, at least with the `getLicense` override method. (An example implementation is provided in the README)

* Ready 5.1.0-alpha6 for release

* Prepare 5.1.0-alpha7

* Port over fix from 4.x branch

* Prepare 5.1.0-alpha8

* Bugfix: TheWidlarzGroup#1930

* Add ARM64 support for windows (TheWidlarzGroup#2137)

Adding arm64 support for RNW builds.

Nothing in this project is using anything that isn't already supported in arm64 windows libs. It was simply overlooked when RNW was originally added.

We have been using RNW and RNV in our project for 6+ months and just been using a patch-package to apply this change. Figured it was overdue to upstream this change.

You can see this similar code in the RNW repo.
https://github.com/microsoft/react-native-windows/blob/95935e008621778dbcec01363602c19abc060632/packages/microsoft-reactnative-sampleapps/windows/SampleLibraryCPP/SampleLibraryCPP.vcxproj#L28
and
https://github.com/microsoft/react-native-windows/blob/master/packages/microsoft-reactnative-sampleapps/windows/SampleLibraryCPP/SampleLibraryCPP.vcxproj#L44

* Update README.md (TheWidlarzGroup#2076)

You only need to perform linking for React Native < 0.60

* fix: Xcode 12 compatibility (TheWidlarzGroup#2152)

Latest Xcode 12 fails to build while without a module to depend on React-Core directly hence this change is necessary for native modules on iOS. This change requires to React Native 0.60.2 or newer. For more details please check: facebook/react-native#29633 (comment)

* Renaming Boolean etc to AsBoolean (TheWidlarzGroup#2119)

* Resolved an issue where setting a video to paused would ignore the “silent switch” setting

* iOS DRM Fixes for License Fetching (TheWidlarzGroup#2208)

* Update package.json version number to 5.1.1

* Update ReactNativeVideoCPP.vcxproj (TheWidlarzGroup#2288)

* Exoplayer: Use okhttp version specified in gradle.properties (TheWidlarzGroup#2340)

Because React Native uses okhttp, including exoplayer causes apps to use two different versions of okhttp.  This results in some unpredictable behavior.  Clients of `react-native-video` should be able to specify the same OKHTTP version to react-native and react-native video.

See where it's specified in react-native trunk: 
- https://github.com/facebook/react-native/blob/master/ReactAndroid/gradle.properties#L15
- https://github.com/facebook/react-native/blob/e1b6cd3f756aa034b11af6bf9960efb42bde8692/ReactAndroid/build.gradle#L452-L453

* React Native Windows updates (TheWidlarzGroup#2206)

Various updates for React Native Windows

**Docs**
* Fixed windows installation in readme
* Added local dev setup instructions

**Build**
* Added VS solutions for RNW 0.61, 0.62, and 0.63+
* Added clang-formatting definition

**Features**
* Fixed autolinking for RNW 0.63+
* Added support for `rate` property

**Examples**
* Upgraded examples/basic to RN 0.61 and replaced broken windows app

* Update README.md (TheWidlarzGroup#2292)

Fix broken link for ignoresilentswitch

* Fix AudoFocus pausing video when attempting to play (TheWidlarzGroup#2311)

Fix AudioFocus bug that could cause the player to stop responding to play/pause in some instances.

Fixes issue TheWidlarzGroup#1945

This was caused by the player requesting audio focus on each play (un-pause) and that resulted in a small window of Audio focus loss and then gain. The focus loss results in the player being paused while the player was supposed to play at the time. The solution is to keep track of Audio focus and not request new focus if we already have it.

* Upgrade ExoPlayer to 2.13.2 (TheWidlarzGroup#2317)

Upgrade ExoPlayer from 2.11.4 to 2.13.2 and fix any issues related to the upgrade and deprecated method use.

* update exoplayer to allow pre-init and content clear

* Fix for tvOS native audio menu language selector

* Release 5.2.0-alpha1

* Typo

* Release 5.2.0

* Use prop types from `deprecated-react-native-prop-types`

Starting with React Native 0.68, using Prop Types from `react-native` emits a warning.

* Update Video.js

Co-authored-by: Elliott Kember <[email protected]>
# Conflicts:
#	Video.js

* Replace Image.propTypes with ImagePropTypes.
# Conflicts:
#	Video.js

* fix(Exoplayer): fix exoplayer version tà 2.13.3

* chore: fix build without exoplayer

* v5.2.1

* docs: update Android installation

* * removed duplicate method

* * fix onRemotePlayPause in android

* * remove duplicate code

* * fix cannot find symbol after RN update

---------

Co-authored-by: Kurt Johnson <[email protected]>
Co-authored-by: Kurt Johnson <[email protected]>
Co-authored-by: vok <[email protected]>
Co-authored-by: Zaid Daghestani <[email protected]>
Co-authored-by: Jens Andersson <[email protected]>
Co-authored-by: Daniel Mariño Ruiz <[email protected]>
Co-authored-by: Daniel Mariño <[email protected]>
Co-authored-by: Ash Mishra <[email protected]>
Co-authored-by: Andrew Chae <[email protected]>
Co-authored-by: Jamie Halvorson <[email protected]>
Co-authored-by: Nahuel Marisi <[email protected]>
Co-authored-by: Jovan Stanimirovic <[email protected]>
Co-authored-by: Benoit Dion <unknown>
Co-authored-by: Benoit Dion <[email protected]>
Co-authored-by: Bader Serhan <[email protected]>
Co-authored-by: Tsukasa Setoguchi <[email protected]>
Co-authored-by: Learnyst <[email protected]>
Co-authored-by: IbrahimSulai <[email protected]>
Co-authored-by: Benoit Dion <[email protected]>
Co-authored-by: Mohammed Salman <[email protected]>
Co-authored-by: Michael Tintiuc <[email protected]>
Co-authored-by: Piotr Błażejewicz (Peter Blazejewicz) <[email protected]>
Co-authored-by: Benoit Dion <[email protected]>
Co-authored-by: Di Da <[email protected]>
Co-authored-by: Brandon Faulkner <[email protected]>
Co-authored-by: Marlon Andrade <[email protected]>
Co-authored-by: Hampton Maxwell <[email protected]>
Co-authored-by: Harrison Mendonça <[email protected]>
Co-authored-by: Evan Bacon <[email protected]>
Co-authored-by: Param Aggarwal <[email protected]>
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]>
Co-authored-by: Tuan Luong <[email protected]>
Co-authored-by: limaAniceto <[email protected]>
Co-authored-by: Anders Lemke <[email protected]>
Co-authored-by: Anton Tanderup <[email protected]>
Co-authored-by: Jeferson Daniel <[email protected]>
Co-authored-by: Daniel Mariño <[email protected]>
Co-authored-by: Hampton Maxwell <[email protected]>
Co-authored-by: Nick Fujita <[email protected]>
Co-authored-by: redspear <[email protected]>
Co-authored-by: Adam Gorman <[email protected]>
Co-authored-by: Irwin <[email protected]>
Co-authored-by: Radek Czemerys <[email protected]>
Co-authored-by: Tero Paananen <[email protected]>
Co-authored-by: Cameron Perry <[email protected]>
Co-authored-by: Alexander Sklar <[email protected]>
Co-authored-by: Sean Holbert <[email protected]>
Co-authored-by: Jon Thysell <[email protected]>
Co-authored-by: Milan Susnjar <[email protected]>
Co-authored-by: Armands Malejev <[email protected]>
Co-authored-by: Jonas Dalesjö <[email protected]>
Co-authored-by: Shane Mckenna <[email protected]>
Co-authored-by: Renaud Chaput <[email protected]>
Co-authored-by: olivier bouillet <[email protected]>
Co-authored-by: Omar Diop <[email protected]>
Co-authored-by: Olivier Bouillet <[email protected]>
Co-authored-by: ARTSOFT\csillaj <[email protected]>
  • Loading branch information
Show file tree
Hide file tree
Showing 75 changed files with 8,610 additions and 4,630 deletions.
3 changes: 1 addition & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"extends": "airbnb",
"parser": "babel-eslint"
"extends": "@react-native-community",
}
66 changes: 66 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

# Bug

<!--
Please provide a clear and concise description of what the bug is.
Include screenshots if needed.
Please test using the latest release of the library, as maybe said bug has been already fixed.
If the library has multiple install methods, describe installation method (e.g., pod, not pod, with jetifier etc)
-->

## Platform
<!--
Platform where your bug is happening. If Android, report if using Android or Android Exoplayer
-->
Which player are you experiencing the problem on:
* iOS
* Android ExoPlayer
* Android MediaPlayer
* Windows UWP
* Windows WPF

## Environment info

<!--
Run `react-native info` in your terminal and copy the results here. Also, include the *precise* version number of this library that you are using in the project
-->

React native info output:

```bash
// paste it here
```

Library version: x.x.x

## Steps To Reproduce

<!--
Issues without reproduction steps or code are likely to stall.
-->

1.
2.
...

## Expected behaviour

1.
2.

## Reproducible sample code

<!--
Please add to your issue a repro, a fresh codebase with the minimal changes so that the bug can be tested in isolation
-->

## Video sample
If possible, include a link to the video that has the problem that can be streamed or downloaded from.
32 changes: 32 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

# Feature Request

<!--
This issue should serve for you to present or pitch an idea to the maintainers - but remember that it would be better if you were to submit a PR instead 🤗
-->

## Why it is needed

<!--
Please tell us a bit more of why you want this feature to be added, what's its origin
-->

## Possible implementation

<!--
It really helps if you could describe from a technical POV how this new feature would work, which code it rely on, etc
-->

### Code sample

<!--
Please show how the new code could work, if doable
-->
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"requirePragma": true,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": false,
"jsxBracketSameLine": true,
"parser": "flow"
}
267 changes: 182 additions & 85 deletions CHANGELOG.md

Large diffs are not rendered by default.

139 changes: 139 additions & 0 deletions DRM.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# DRM

## Provide DRM data (only tested with http/https assets)

You can provide some configuration to allow DRM playback.
This feature will disable the use of `TextureView` on Android.

DRM object allows this members:

| Property | Type | Default | Platform | Description |
| --- | --- | --- | --- | --- |
| [`type`](#type) | DRMType | undefined | iOS/Android | Specifies which type of DRM you are going to use, DRMType is an enum exposed on the JS module ('fairplay', 'playready', ...) |
| [`licenseServer`](#licenseserver) | string | undefined | iOS/Android | Specifies the license server URL |
| [`headers`](#headers) | Object | undefined | iOS/Android | Specifies the headers send to the license server URL on license acquisition |
| [`contentId`](#contentid) | string | undefined | iOS | Specify the content id of the stream, otherwise it will take the host value from `loadingRequest.request.URL.host` (f.e: `skd://testAsset` -> will take `testAsset`) |
| [`certificateUrl`](#certificateurl) | string | undefined | iOS | Specifies the url to obtain your ios certificate for fairplay, Url to the .cer file |
| [`base64Certificate`](#base64certificate) | bool | false | iOS | Specifies whether or not the certificate returned by the `certificateUrl` is on base64 |
| [`getLicense`](#getlicense)| function | undefined | iOS | Rather than setting the `licenseServer` url to get the license, you can manually get the license on the JS part, and send the result to the native part to configure FairplayDRM for the stream |

### `base64Certificate`

Whether or not the certificate url returns it on base64.

Platforms: iOS

### `certificateUrl`

URL to fetch a valid certificate for FairPlay.

Platforms: iOS

### `getLicense`

`licenseServer` and `headers` will be ignored. You will obtain as argument the `SPC` (as ASCII string, you will probably need to convert it to base 64) obtained from your `contentId` + the provided certificate via `[loadingRequest streamingContentKeyRequestDataForApp:certificateData contentIdentifier:contentIdData options:nil error:&spcError];`.
You should return on this method a `CKC` in Base64, either by just returning it or returning a `Promise` that resolves with the `CKC`.

With this prop you can override the license acquisition flow, as an example:

```js
getLicense: (spcString) => {
const base64spc = Base64.encode(spcString);
const formData = new FormData();
formData.append('spc', base64spc);
return fetch(`https://license.pallycon.com/ri/licenseManager.do`, {
method: 'POST',
headers: {
'pallycon-customdata-v2': 'd2VpcmRiYXNlNjRzdHJpbmcgOlAgRGFuaWVsIE1hcmnxbyB3YXMgaGVyZQ==',
'Content-Type': 'application/x-www-form-urlencoded',
},
body: formData
}).then(response => response.text()).then((response) => {
return response;
}).catch((error) => {
console.error('Error', error);
});
}
```

Platforms: iOS

### `headers`

You can customize headers send to the licenseServer.

Example:

```js
source={{
uri: 'https://media.axprod.net/TestVectors/v7-MultiDRM-SingleKey/Manifest_1080p.mpd',
}}
drm={{
type: DRMType.WIDEVINE,
licenseServer: 'https://drm-widevine-licensing.axtest.net/AcquireLicense',
headers: {
'X-AxDRM-Message': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ2ZXJzaW9uIjoxLCJjb21fa2V5X2lkIjoiYjMzNjRlYjUtNTFmNi00YWUzLThjOTgtMzNjZWQ1ZTMxYzc4IiwibWVzc2FnZSI6eyJ0eXBlIjoiZW50aXRsZW1lbnRfbWVzc2FnZSIsImZpcnN0X3BsYXlfZXhwaXJhdGlvbiI6NjAsInBsYXlyZWFkeSI6eyJyZWFsX3RpbWVfZXhwaXJhdGlvbiI6dHJ1ZX0sImtleXMiOlt7ImlkIjoiOWViNDA1MGQtZTQ0Yi00ODAyLTkzMmUtMjdkNzUwODNlMjY2IiwiZW5jcnlwdGVkX2tleSI6ImxLM09qSExZVzI0Y3Iya3RSNzRmbnc9PSJ9XX19.FAbIiPxX8BHi9RwfzD7Yn-wugU19ghrkBFKsaCPrZmU'
},
}}
```

### `licenseServer`

The URL pointing to the licenseServer that will provide the authorization to play the protected stream.

### `type`

You can specify the DRM type, either by string or using the exported DRMType enum.
Valid values are, for Android: DRMType.WIDEVINE / DRMType.PLAYREADY / DRMType.CLEARKEY.
for iOS: DRMType.FAIRPLAY

## Common Usage Scenarios

### Send cookies to license server

You can send Cookies to the license server via `headers` prop. Example:

```js
drm: {
type: DRMType.WIDEVINE
licenseServer: 'https://drm-widevine-licensing.axtest.net/AcquireLicense',
headers: {
'Cookie': 'PHPSESSID=etcetc; csrftoken=mytoken; _gat=1; foo=bar'
},
}
```

### Custom License Acquisition (only iOS for now)

```js
drm: {
type: DRMType.FAIRPLAY,
getLicense: (spcString) => {
const base64spc = Base64.encode(spcString);
return fetch('YOUR LICENSE SERVER HERE', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
},
body: JSON.stringify({
getFairplayLicense: {
foo: 'bar',
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);
});
}
}
```
50 changes: 36 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ Select RCTVideo-tvOS
Linking is not required in React Native 0.60 and above.
If your project is using React Native < 0.60, run `react-native link react-native-video` to link the react-native-video library.

Or if you have trouble, make the following additions to the given files manually:
Note that with Autolinking the old Android MediaPlayer based player is used.

If you have trouble or if you want to manually select the player to use, make the following additions to the given files manually:

#### **android/settings.gradle**

Expand Down Expand Up @@ -187,32 +189,46 @@ protected List<ReactPackage> getPackages() {
<details>
<summary>Windows RNW C++/WinRT details</summary>

#### Autolinking

**React Native Windows 0.63 and above**

Autolinking should automatically add react-native-video to your app.

#### Manual Linking

**React Native Windows 0.62**

Make the following additions to the given files manually:

#### **windows/myapp.sln**
##### **windows\myapp.sln**

Add the `ReactNativeVideoCPP` project to your solution.
Add the _ReactNativeVideoCPP_ project to your solution (eg. `windows\myapp.sln`):

1. Open the solution in Visual Studio 2019
2. Right-click Solution icon in Solution Explorer > Add > Existing Project
Select `node_modules\react-native-video\windows\ReactNativeVideoCPP\ReactNativeVideoCPP.vcxproj`
1. Open your solution in Visual Studio 2019
2. Right-click Solution icon in Solution Explorer > Add > Existing Project...
3. Select `node_modules\react-native-video\windows\ReactNativeVideoCPP\ReactNativeVideoCPP.vcxproj`

#### **windows/myapp/myapp.vcxproj**
##### **windows\myapp\myapp.vcxproj**

Add a reference to `ReactNativeVideoCPP` to your main application project. From Visual Studio 2019:
Add a reference to _ReactNativeVideoCPP_ to your main application project (eg. `windows\myapp\myapp.vcxproj`):

1. Right-click main application project > Add > Reference...
Check `ReactNativeVideoCPP` from Solution Projects.
1. Open your solution in Visual Studio 2019
2. Right-click main application project > Add > Reference...
3. Check _ReactNativeVideoCPP_ from Solution Projects

2. Modify files below to add the video package providers to your main application project
#### **pch.h**
##### **pch.h**

Add `#include "winrt/ReactNativeVideoCPP.h"`.

#### **app.cpp**
##### **app.cpp**

Add `PackageProviders().Append(winrt::ReactNativeVideoCPP::ReactPackageProvider());` before `InitializeComponent();`.

**React Native Windows 0.61 and below**

Follow the manual linking instuctions for React Native Windows 0.62 above, but substitute _ReactNativeVideoCPP61_ for _ReactNativeVideoCPP_.

</details>

### react-native-dom installation
Expand Down Expand Up @@ -756,6 +772,12 @@ Platforms: Android ExoPlayer
#### source
Sets the media source. You can pass an asset loaded via require or an object with a uri.

Setting the source will trigger the player to attempt to load the provided media with all other given props. Please be sure that all props are provided before/at the same time as setting the source.

Rendering the player component with a null source will init the player, and start playing once a source value is provided.

Providing a null source value after loading a previous source will stop playback, and clear out the previous source content.

The docs for this prop are incomplete and will be updated as each option is investigated and tested.


Expand Down Expand Up @@ -1302,7 +1324,7 @@ On iOS, if you would like to allow other apps to play music over your video comp
}
```

You can also use the [ignoreSilentSwitch](ignoresilentswitch) prop.
You can also use the [ignoreSilentSwitch](#ignoresilentswitch) prop.
</details>

### Android Expansion File Usage
Expand Down
8 changes: 4 additions & 4 deletions Video.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { StyleSheet, requireNativeComponent, NativeModules, View, Image, Platform, findNodeHandle } from 'react-native';
import { ViewPropTypes } from 'deprecated-react-native-prop-types';
import { ViewPropTypes, ImagePropTypes } from 'deprecated-react-native-prop-types';
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
import TextTrackType from './TextTrackType';
import FilterType from './FilterType';
Expand Down Expand Up @@ -243,8 +243,8 @@ export default class Video extends Component {
_onGetLicense = (event) => {
if (this.props.drm && this.props.drm.getLicense instanceof Function) {
const data = event.nativeEvent;
if (data && data.spc) {
const getLicenseOverride = this.props.drm.getLicense(data.spc, data.contentId, data.spcBase64, this.props);
if (data && data.spcBase64) {
const getLicenseOverride = this.props.drm.getLicense(data.spcBase64, data.contentId, data.licenseUrl);
const getLicensePromise = Promise.resolve(getLicenseOverride); // Handles both scenarios, getLicenseOverride being a promise and not.
getLicensePromise.then((result => {
if (result !== undefined) {
Expand Down Expand Up @@ -423,7 +423,7 @@ Video.propTypes = {
maxBitRate: PropTypes.number,
resizeMode: PropTypes.string,
poster: PropTypes.string,
posterResizeMode: Image.propTypes.resizeMode,
posterResizeMode: ImagePropTypes.resizeMode,
repeat: PropTypes.bool,
automaticallyWaitsToMinimizeStalling: PropTypes.bool,
allowsExternalPlayback: PropTypes.bool,
Expand Down
6 changes: 3 additions & 3 deletions android-exoplayer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ android {

dependencies {
implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
implementation('com.google.android.exoplayer:exoplayer:2.11.4') {
implementation('com.google.android.exoplayer:exoplayer:2.13.3') {
exclude group: 'com.android.support'
}

Expand All @@ -37,9 +37,9 @@ dependencies {
implementation "androidx.core:core:1.1.0"
implementation "androidx.media:media:1.1.0"

implementation('com.google.android.exoplayer:extension-okhttp:2.11.4') {
implementation('com.google.android.exoplayer:extension-okhttp:2.13.3') {
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
implementation 'com.squareup.okhttp3:okhttp:3.14.3'
implementation 'com.squareup.okhttp3:okhttp:${OKHTTP_VERSION}'

}
Loading

0 comments on commit 4cbc60a

Please sign in to comment.