@jwplayer/jwplayer-react-native 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/CODEOWNERS +2 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/.github/ISSUE_TEMPLATE/question.md +11 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +15 -0
- package/CODE_OF_CONDUCT.md +128 -0
- package/LICENSE +21 -0
- package/README.md +425 -0
- package/RNJWPlayer.podspec +44 -0
- package/android/.gradle/8.1.1/checksums/checksums.lock +0 -0
- package/android/.gradle/8.1.1/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/8.1.1/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.1.1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.1.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.1.1/gc.properties +0 -0
- package/android/.gradle/8.2/checksums/checksums.lock +0 -0
- package/android/.gradle/8.2/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/8.2/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.2/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.2/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.2/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/config.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/gradle.xml +12 -0
- package/android/.idea/migrations.xml +10 -0
- package/android/.idea/misc.xml +10 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/.idea/workspace.xml +54 -0
- package/android/build.gradle +110 -0
- package/android/local.properties +8 -0
- package/android/src/main/AndroidManifest.xml +25 -0
- package/android/src/main/java/com/jwplayer/rnjwplayer/ArrayUtil.java +129 -0
- package/android/src/main/java/com/jwplayer/rnjwplayer/CastOptionsProvider.java +55 -0
- package/android/src/main/java/com/jwplayer/rnjwplayer/MapUtil.java +136 -0
- package/android/src/main/java/com/jwplayer/rnjwplayer/RNJWPlayer.java +76 -0
- package/android/src/main/java/com/jwplayer/rnjwplayer/RNJWPlayerAds.java +239 -0
- package/android/src/main/java/com/jwplayer/rnjwplayer/RNJWPlayerModule.java +526 -0
- package/android/src/main/java/com/jwplayer/rnjwplayer/RNJWPlayerPackage.java +30 -0
- package/android/src/main/java/com/jwplayer/rnjwplayer/RNJWPlayerView.java +1499 -0
- package/android/src/main/java/com/jwplayer/rnjwplayer/RNJWPlayerViewManager.java +171 -0
- package/android/src/main/java/com/jwplayer/rnjwplayer/Util.java +219 -0
- package/android/src/main/java/com/jwplayer/rnjwplayer/WidevineCallback.java +62 -0
- package/badges/license.svg +1 -0
- package/badges/version.svg +1 -0
- package/docs/legacy_readme.md +634 -0
- package/docs/props.md +43 -0
- package/docs/types.md +254 -0
- package/index.d.ts +564 -0
- package/index.js +699 -0
- package/ios/RNJWPlayer/RCTConvert+RNJWPlayer.swift +119 -0
- package/ios/RNJWPlayer/RNJWPlayer-Bridging-Header.h +5 -0
- package/ios/RNJWPlayer/RNJWPlayerAds.swift +260 -0
- package/ios/RNJWPlayer/RNJWPlayerModels.swift +149 -0
- package/ios/RNJWPlayer/RNJWPlayerView.swift +1837 -0
- package/ios/RNJWPlayer/RNJWPlayerViewController.swift +616 -0
- package/ios/RNJWPlayer/RNJWPlayerViewManager.m +132 -0
- package/ios/RNJWPlayer/RNJWPlayerViewManager.swift +500 -0
- package/ios/RNJWPlayer.xcodeproj/project.pbxproj +323 -0
- package/package.json +45 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Create a report to help us improve
|
|
4
|
+
title: "[BUG]"
|
|
5
|
+
labels: ''
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Describe the bug**
|
|
11
|
+
A clear and concise description of what the bug is.
|
|
12
|
+
|
|
13
|
+
**To Reproduce**
|
|
14
|
+
Use the `Example` application as reference material and a starting place to reproduce any bugs.
|
|
15
|
+
|
|
16
|
+
***Steps to reproduce the behavior:***
|
|
17
|
+
1. Provide thorough
|
|
18
|
+
2. And complete
|
|
19
|
+
3. Steps for reproduction
|
|
20
|
+
4. That are reliably reproducible
|
|
21
|
+
|
|
22
|
+
**Expected behavior**
|
|
23
|
+
A clear and concise description of what you expected to happen.
|
|
24
|
+
|
|
25
|
+
**Screenshots / Visual evidence**
|
|
26
|
+
If applicable, add screenshots or recordings to help explain your problem. (Required if reproduction is not 100% reliable)
|
|
27
|
+
|
|
28
|
+
**Desktop (please complete the following information):**
|
|
29
|
+
If you are having a build issue, we would like to know about your machine.
|
|
30
|
+
- Result of `npx react-native info`
|
|
31
|
+
|
|
32
|
+
**Device(s) affected**
|
|
33
|
+
- Device: [e.g. iPhone6]
|
|
34
|
+
- OS: [e.g. iOS8.1]
|
|
35
|
+
- Version [e.g. 22]
|
|
36
|
+
|
|
37
|
+
**Additional context**
|
|
38
|
+
Add any other context about the problem here.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature request
|
|
3
|
+
about: Suggest an idea for this project
|
|
4
|
+
title: "[FEAT]"
|
|
5
|
+
labels: ''
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Is your feature request related to a problem? Please describe.**
|
|
11
|
+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
12
|
+
|
|
13
|
+
**Describe the solution you'd like**
|
|
14
|
+
A clear and concise description of what you want to happen.
|
|
15
|
+
|
|
16
|
+
**Describe alternatives you've considered**
|
|
17
|
+
A clear and concise description of any alternative solutions or features you've considered.
|
|
18
|
+
|
|
19
|
+
**Additional context**
|
|
20
|
+
Add any other context or screenshots about the feature request here.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
### What does this Pull Request do?
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Why is this Pull Request needed?
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
### Are there any points in the code the reviewer needs to double check?
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Are there any Pull Requests open in other repos which need to be merged with this?
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
#### Addresses Issue(s):
|
|
14
|
+
|
|
15
|
+
[GitHub Issue](https://github.com/jwplayer/jwplayer-react-native/issues/###)
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity
|
|
10
|
+
and orientation.
|
|
11
|
+
|
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
+
diverse, inclusive, and healthy community.
|
|
14
|
+
|
|
15
|
+
## Our Standards
|
|
16
|
+
|
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
|
18
|
+
community include:
|
|
19
|
+
|
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
+
and learning from the experience
|
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the
|
|
26
|
+
overall community
|
|
27
|
+
|
|
28
|
+
Examples of unacceptable behavior include:
|
|
29
|
+
|
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or
|
|
31
|
+
advances of any kind
|
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
33
|
+
* Public or private harassment
|
|
34
|
+
* Publishing others' private information, such as a physical or email
|
|
35
|
+
address, without their explicit permission
|
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
+
professional setting
|
|
38
|
+
|
|
39
|
+
## Enforcement Responsibilities
|
|
40
|
+
|
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
44
|
+
or harmful.
|
|
45
|
+
|
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
49
|
+
decisions when appropriate.
|
|
50
|
+
|
|
51
|
+
## Scope
|
|
52
|
+
|
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
54
|
+
an individual is officially representing the community in public spaces.
|
|
55
|
+
Examples of representing our community include using an official e-mail address,
|
|
56
|
+
posting via an official social media account, or acting as an appointed
|
|
57
|
+
representative at an online or offline event.
|
|
58
|
+
|
|
59
|
+
## Enforcement
|
|
60
|
+
|
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
62
|
+
reported to the community leaders responsible for enforcement at
|
|
63
|
+
conduct@jwplayer.com.
|
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
65
|
+
|
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
|
67
|
+
reporter of any incident.
|
|
68
|
+
|
|
69
|
+
## Enforcement Guidelines
|
|
70
|
+
|
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
|
73
|
+
|
|
74
|
+
### 1. Correction
|
|
75
|
+
|
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
77
|
+
unprofessional or unwelcome in the community.
|
|
78
|
+
|
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
|
82
|
+
|
|
83
|
+
### 2. Warning
|
|
84
|
+
|
|
85
|
+
**Community Impact**: A violation through a single incident or series
|
|
86
|
+
of actions.
|
|
87
|
+
|
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
|
92
|
+
like social media. Violating these terms may lead to a temporary or
|
|
93
|
+
permanent ban.
|
|
94
|
+
|
|
95
|
+
### 3. Temporary Ban
|
|
96
|
+
|
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
|
98
|
+
sustained inappropriate behavior.
|
|
99
|
+
|
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
|
101
|
+
communication with the community for a specified period of time. No public or
|
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
|
104
|
+
Violating these terms may lead to a permanent ban.
|
|
105
|
+
|
|
106
|
+
### 4. Permanent Ban
|
|
107
|
+
|
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
|
111
|
+
|
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within
|
|
113
|
+
the community.
|
|
114
|
+
|
|
115
|
+
## Attribution
|
|
116
|
+
|
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
118
|
+
version 2.0, available at
|
|
119
|
+
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
|
120
|
+
|
|
121
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
|
122
|
+
enforcement ladder](https://github.com/mozilla/diversity).
|
|
123
|
+
|
|
124
|
+
[homepage]: https://www.contributor-covenant.org
|
|
125
|
+
|
|
126
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
127
|
+
https://www.contributor-covenant.org/faq. Translations are available at
|
|
128
|
+
https://www.contributor-covenant.org/translations.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 JW Player
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
# jwplayer-react-native
|
|
2
|
+
|
|
3
|
+
[](https://github.com/jwplayer/jwplayer-react-native) [](https://www.npmjs.com/package/@jwplayer/jwplayer-react-native) [](/LICENSE)
|
|
4
|
+
|
|
5
|
+
⚠️ This **README** is for `jwplayer-react-native` version `1.0.0` and higher, for previous versions from the original author, [Chaim Paneth](https://github.com/chaimPaneth) via [Orthodox Union](https://www.ou.org/), see [react-native-jw-media-player](https://github.com/chaimPaneth/react-native-jw-media-player). Beginning with version `0.2.0`, this library uses [JWP's `JWPlayerKit ` (iOS)]((https://developer.jwplayer.com/jwplayer/docs/ios-get-started)) and [SDK 4 (Android)]((https://developer.jwplayer.com/jwplayer/docs/android-get-started)).
|
|
6
|
+
|
|
7
|
+
<br />
|
|
8
|
+
|
|
9
|
+
[Prerequisites](#prerequisites) | [Installation](#installation) | [Usage](#usage) | [Advanced Topics](#advanced-topics) | [Contributing](#contributing) | [Issues](#issues)
|
|
10
|
+
|
|
11
|
+
<br />
|
|
12
|
+
|
|
13
|
+
The `jwplayer-react-native` library is a bridge that enables using the native JWP Android and iOS SDKs in React Native applications.
|
|
14
|
+
|
|
15
|
+
<img width="200" alt="sample" src="./images/1.png"> <img width="200" alt="sample" src="./images/2.png"> <img width="200" alt="sample" src="./images/3.png">
|
|
16
|
+
|
|
17
|
+
<br /><br />
|
|
18
|
+
|
|
19
|
+
## Prerequisites
|
|
20
|
+
|
|
21
|
+
Before installing and using the library, you need the following items:
|
|
22
|
+
- JWP [Account](https://jwplayer.com/pricing/)
|
|
23
|
+
- JWP License Key ([Android](https://docs.jwplayer.com/players/docs/android-overview#requirements) | [iOS](https://docs.jwplayer.com/players/docs/ios-overview#requirements))
|
|
24
|
+
- [React Native App](https://reactnative.dev/docs/getting-started)
|
|
25
|
+
- Package Manager ([npm](https://nodejs.org/en/download) | [yarn](https://yarnpkg.com/getting-started/install) )
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
<br /><br />
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
[Android](#android) | [iOS](#ios)
|
|
32
|
+
|
|
33
|
+
### Android
|
|
34
|
+
Follow these steps to add the library to your Android project:
|
|
35
|
+
1. From the project directory in terminal, add the **jwplayer-react-native** library. You can use npm or yarn.
|
|
36
|
+
|
|
37
|
+
npm: `npm i @jwplayer/jwplayer-react-native --save`
|
|
38
|
+
|
|
39
|
+
yarn: `yarn add @jwplayer/jwplayer-react-native`
|
|
40
|
+
|
|
41
|
+
2. In **android/build.gradle**, add the JWP Maven repository inside the `allprojects` block.
|
|
42
|
+
|
|
43
|
+
```groovy
|
|
44
|
+
allprojects {
|
|
45
|
+
repositories {
|
|
46
|
+
...
|
|
47
|
+
maven {
|
|
48
|
+
url 'https://mvn.jwplayer.com/content/repositories/releases/'
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
<br /><br />
|
|
54
|
+
|
|
55
|
+
### iOS
|
|
56
|
+
|
|
57
|
+
Follow these steps to add the library to your iOS project:
|
|
58
|
+
1. From the project directory in terminal, add the **jwplayer-react-native** library. You can use npm or yarn.
|
|
59
|
+
|
|
60
|
+
npm: `npm i @jwplayer/jwplayer-react-native --save`
|
|
61
|
+
|
|
62
|
+
yarn: `yarn add @jwplayer/jwplayer-react-native`
|
|
63
|
+
|
|
64
|
+
2. Change the directory to the iOS folder of your React Native project.
|
|
65
|
+
```
|
|
66
|
+
cd ios/
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
3. Install the iOS dependencies with CocoaPods.
|
|
70
|
+
```
|
|
71
|
+
pod install
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
<br /><br />
|
|
75
|
+
|
|
76
|
+
## Usage
|
|
77
|
+
|
|
78
|
+
The following example shows how you can enhance your React Native application by seamlessly integrating the multimedia playback functionalities of the JWP mobile SDKs.
|
|
79
|
+
|
|
80
|
+
Follow these steps to configure the media playback experience in your app:
|
|
81
|
+
|
|
82
|
+
1. Use the following example as a guide to configure the media playback experience. Be sure to remove all instances of `...` from the code.
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
```javascript
|
|
86
|
+
...
|
|
87
|
+
|
|
88
|
+
import JWPlayer, { JWPlayerState } from '@jwplayer/jwplayer-react-native';
|
|
89
|
+
|
|
90
|
+
...
|
|
91
|
+
|
|
92
|
+
const styles = StyleSheet.create({
|
|
93
|
+
container: {
|
|
94
|
+
flex: 1,
|
|
95
|
+
},
|
|
96
|
+
player: {
|
|
97
|
+
flex: 1,
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
...
|
|
102
|
+
|
|
103
|
+
const playlistItem = {
|
|
104
|
+
title: 'Track',
|
|
105
|
+
mediaId: -1,
|
|
106
|
+
image: 'http://image.com/image.png',
|
|
107
|
+
description: 'My beautiful track',
|
|
108
|
+
startTime: 0,
|
|
109
|
+
file: 'http://file.com/file.mp3',
|
|
110
|
+
tracks: [
|
|
111
|
+
{
|
|
112
|
+
file: 'http://file.com/english.vtt',
|
|
113
|
+
label: 'en',
|
|
114
|
+
default: true
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
file: 'http://file.com/spanish.srt',
|
|
118
|
+
label: 'es'
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
sources: [
|
|
122
|
+
{
|
|
123
|
+
file: 'http://file.com/file.mp3',
|
|
124
|
+
label: 'audio'
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
file: 'http://file.com/file.mp4',
|
|
128
|
+
label: 'video',
|
|
129
|
+
default: true
|
|
130
|
+
}
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const config = {
|
|
135
|
+
license:
|
|
136
|
+
Platform.OS === 'android'
|
|
137
|
+
? 'YOUR_ANDROID_SDK_KEY'
|
|
138
|
+
: 'YOUR_IOS_SDK_KEY',
|
|
139
|
+
backgroundAudioEnabled: true,
|
|
140
|
+
autostart: true,
|
|
141
|
+
styling: {
|
|
142
|
+
colors: {
|
|
143
|
+
timeslider: {
|
|
144
|
+
rail: "0000FF",
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
playlist: [playlistItem],
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
...
|
|
152
|
+
|
|
153
|
+
async isPlaying() {
|
|
154
|
+
const playerState = await this.JWPlayer.playerState();
|
|
155
|
+
return playerState === JWPlayerState.JWPlayerStatePlaying;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
...
|
|
159
|
+
|
|
160
|
+
render() {
|
|
161
|
+
|
|
162
|
+
...
|
|
163
|
+
|
|
164
|
+
<View style={styles.container}>
|
|
165
|
+
<JWPlayer
|
|
166
|
+
ref={p => (this.JWPlayer = p)}
|
|
167
|
+
style={styles.player}
|
|
168
|
+
config={config}
|
|
169
|
+
onBeforePlay={() => this.onBeforePlay()}
|
|
170
|
+
onPlay={() => this.onPlay()}
|
|
171
|
+
onPause={() => this.onPause()}
|
|
172
|
+
onIdle={() => console.log("onIdle")}
|
|
173
|
+
onPlaylistItem={event => this.onPlaylistItem(event)}
|
|
174
|
+
onSetupPlayerError={event => this.onPlayerError(event)}
|
|
175
|
+
onPlayerError={event => this.onPlayerError(event)}
|
|
176
|
+
onBuffer={() => this.onBuffer()}
|
|
177
|
+
onTime={event => this.onTime(event)}
|
|
178
|
+
onFullScreen={() => this.onFullScreen()}
|
|
179
|
+
onFullScreenExit={() => this.onFullScreenExit()}
|
|
180
|
+
/>
|
|
181
|
+
</View>
|
|
182
|
+
|
|
183
|
+
...
|
|
184
|
+
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
2. Define `config.license` with your Android or iOS JWP license key.
|
|
190
|
+
3. Define `config.playlist` with the media to play in the player.
|
|
191
|
+
4. (Optional) Define the other values of the `config` prop.
|
|
192
|
+
|
|
193
|
+
<br />
|
|
194
|
+
|
|
195
|
+
ℹ️ See [Props](/docs/props.md) for all the available `config` prop fields.
|
|
196
|
+
|
|
197
|
+
ℹ️ See [Legacy Readme](/docs/legacy_readme.md) for all the available `config` prop fields when using a legacy configuration.
|
|
198
|
+
|
|
199
|
+
<br />
|
|
200
|
+
|
|
201
|
+
### Example Project
|
|
202
|
+
|
|
203
|
+
This repository contains the **Example** project. This project showcases several basic implementations of the `<JWPlayer>` view and can be used as a resource while working with the `jwplayer-react-native` library:
|
|
204
|
+
|
|
205
|
+
- Test pull requests (PRs) or modifications
|
|
206
|
+
- Experiment with the available media playback features
|
|
207
|
+
- Validate your configurations in a known, working application
|
|
208
|
+
- Demonstrate issues within a sanitary environment when submitting bugs
|
|
209
|
+
|
|
210
|
+
<br />
|
|
211
|
+
|
|
212
|
+
Follow these steps to run the example project:
|
|
213
|
+
|
|
214
|
+
1. Checkout this repository.
|
|
215
|
+
2. From the **Example** directory, run `yarn` or `npm i`.
|
|
216
|
+
3. From the **Example/ios** directory, install the iOS dependencies.
|
|
217
|
+
```
|
|
218
|
+
pod install
|
|
219
|
+
```
|
|
220
|
+
4. In Xcode,open **RNJWPlayer.xcworkspace**.
|
|
221
|
+
5. In **App.js**, within the `config` prop, add your JWP SDK license key.
|
|
222
|
+
6. Build and run the app for your preferred platform.
|
|
223
|
+
```
|
|
224
|
+
yarn android
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
OR
|
|
228
|
+
|
|
229
|
+
```
|
|
230
|
+
yarn ios
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
<br />
|
|
234
|
+
|
|
235
|
+
ℹ️ You can also build and run the app with specific `react-native` commands.
|
|
236
|
+
|
|
237
|
+
<br /><br />
|
|
238
|
+
|
|
239
|
+
## Advanced Topics
|
|
240
|
+
|
|
241
|
+
[Advertising](#advertising) | [Background Audio](#background-audio) | [Casting](#casting) | [DRM](#drm) | [Picture in Picture (PiP)](#picture-in-picture-pip)
|
|
242
|
+
|
|
243
|
+
<br />
|
|
244
|
+
|
|
245
|
+
### Advertising
|
|
246
|
+
|
|
247
|
+
[Android](#android-advertising) | [iOS](#ios-advertising)
|
|
248
|
+
|
|
249
|
+
#### Android Advertising
|
|
250
|
+
|
|
251
|
+
Follow this step to set up advertising with IMA or DAI:
|
|
252
|
+
|
|
253
|
+
1. In the **app/build.gradle** `ext{}`, add `RNJWPlayerUseGoogleIMA = true`. This setting will add the following dependencies: `com.google.ads.interactivemedia.v3:interactivemedia:3.31.0` and `com.google.android.gms:play-services-ads-identifier:18.0.1`.
|
|
254
|
+
|
|
255
|
+
<br />
|
|
256
|
+
|
|
257
|
+
#### iOS Advertising
|
|
258
|
+
|
|
259
|
+
Follow this step to set up advertising with IMA or DAI:
|
|
260
|
+
|
|
261
|
+
1. In the **Podfile** `ext{}`, add `$RNJWPlayerUseGoogleIMA = true`. This setting will add `GoogleAds-IMA-iOS-SDK` to the pod.
|
|
262
|
+
|
|
263
|
+
<br /><br />
|
|
264
|
+
|
|
265
|
+
### Background Audio
|
|
266
|
+
|
|
267
|
+
Background Audio allows your viewers to play audio while they are no longer actively using your app or have locked their device.
|
|
268
|
+
|
|
269
|
+
Follow these steps to enable background audio sessions:
|
|
270
|
+
|
|
271
|
+
1. Set `backgroundAudioEnabled` to `true` in the `config`.
|
|
272
|
+
2. Ensure that background audio is set for [Android](https://docs.jwplayer.com/players/docs/android-enable-background-audio) or [iOS](https://docs.jwplayer.com/players/docs/ios-player-backgrounding-reference#configure-audio-playback).
|
|
273
|
+
|
|
274
|
+
<br /><br />
|
|
275
|
+
|
|
276
|
+
### Casting
|
|
277
|
+
|
|
278
|
+
[Android](#android-casting) | [iOS](#ios-casting)
|
|
279
|
+
|
|
280
|
+
JWP enables casting by default with a casting button.
|
|
281
|
+
|
|
282
|
+
<br />
|
|
283
|
+
|
|
284
|
+
#### Android Casting
|
|
285
|
+
|
|
286
|
+
Follow these steps to enable casting:
|
|
287
|
+
|
|
288
|
+
1. In **app/build.gradle** in `ext{}`, add `RNJWPlayerUseGoogleCast = true`.
|
|
289
|
+
2. In **app/build.gradle**, add `com.google.android.gms:play-services-cast-framework:21.3.0`.
|
|
290
|
+
3. Create a class that overrides `OptionsProvider` in your Android codebase:
|
|
291
|
+
1. See the reference file **android/src/main/java/com/appgoalz/rnjwplayer/CastOptionsProvider.java**.
|
|
292
|
+
2. Replace `.setTargetActivityClassName(RNJWPlayerView.class.getName())` with your player Activity.
|
|
293
|
+
3. Modify the file with any options necessary for your use case.
|
|
294
|
+
4. Add the `meta-data` to your **AndroidManifest.xml**.
|
|
295
|
+
|
|
296
|
+
```xml
|
|
297
|
+
<meta-data
|
|
298
|
+
android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
|
|
299
|
+
android:value="path.to.CastOptionsProvider" />
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
<br />
|
|
303
|
+
|
|
304
|
+
#### iOS Casting
|
|
305
|
+
|
|
306
|
+
Follow these steps to enable casting:
|
|
307
|
+
|
|
308
|
+
1. [Enable casting to Chromecast devices](https://docs.jwplayer.com/players/docs/ios-enable-casting-to-chromecast-devices).
|
|
309
|
+
2. Add `$RNJWPlayerUseGoogleCast = true` to your **Podfile**. This setting will install `google-cast-sdk` pod.
|
|
310
|
+
3. Edit **Info.plist** with the following values.
|
|
311
|
+
|
|
312
|
+
```text
|
|
313
|
+
'NSBluetoothAlwaysUsageDescription' => 'We will use your Bluetooth for media casting.',
|
|
314
|
+
'NSBluetoothPeripheralUsageDescription' => 'We will use your Bluetooth for media casting.',
|
|
315
|
+
'NSLocalNetworkUsageDescription' => 'We will use the local network to discover Cast-enabled devices on your WiFi network.',
|
|
316
|
+
'Privacy - Local Network Usage Description' => 'We will use the local network to discover Cast-enabled devices on your WiFi network.'
|
|
317
|
+
'NSMicrophoneUsageDescription' => 'We will use your Microphone for media casting.'
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
<br />
|
|
321
|
+
|
|
322
|
+
| Available Method | Description |
|
|
323
|
+
| --- | --- |
|
|
324
|
+
| `castState(GCKCastState)` | Gets the cast state<br />See: [GCKCastState](#gckcaststate) |
|
|
325
|
+
|
|
326
|
+
##### GCKCastState
|
|
327
|
+
|
|
328
|
+
```text
|
|
329
|
+
typedef NS_ENUM(NSUInteger, GCKCastState) {
|
|
330
|
+
/** No Cast session is established, and no Cast devices are available. */
|
|
331
|
+
GCKCastStateNoDevicesAvailable = 0,
|
|
332
|
+
/** No Cast session is establishd, and Cast devices are available. */
|
|
333
|
+
GCKCastStateNotConnected = 1,
|
|
334
|
+
/** A Cast session is being established. */
|
|
335
|
+
GCKCastStateConnecting = 2,
|
|
336
|
+
/** A Cast session is established. */
|
|
337
|
+
GCKCastStateConnected = 3,
|
|
338
|
+
};
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
<br /><br />
|
|
342
|
+
|
|
343
|
+
### DRM
|
|
344
|
+
|
|
345
|
+
Enable digital rights management (DRM) protected playback.
|
|
346
|
+
|
|
347
|
+
💡 Check out the **DRMExample** in the **Example** app. The **DRMExample** cannot be run in the Simulator. Additionally, the window will not show on an Android Emulator.
|
|
348
|
+
|
|
349
|
+
<br />
|
|
350
|
+
|
|
351
|
+
#### Android DRM
|
|
352
|
+
|
|
353
|
+
Only Widevine is supported.
|
|
354
|
+
|
|
355
|
+
Follow these steps to enable DRM:
|
|
356
|
+
1. Set up your Android app for [DRM playback](https://developer.jwplayer.com/jwplayer/docs/android-play-drm-protected-content).
|
|
357
|
+
2. Define `config.playlist` with the [JWP signed URL](https://docs.jwplayer.com/platform/docs/protection-studio-drm-generate-a-signed-content-url-for-drm-playback) of the media to play in the player.
|
|
358
|
+
|
|
359
|
+
*❗️DO NOT sign and store your API secerets from your application.❗️*
|
|
360
|
+
|
|
361
|
+
If you use a different provider for DRM or this does not work for your use case, conforming to a similiar format as a JWP signed URL response is optimal, such as adding the `drm` field to the `sources` for a playlist item).
|
|
362
|
+
|
|
363
|
+
<br />
|
|
364
|
+
|
|
365
|
+
#### iOS DRM
|
|
366
|
+
|
|
367
|
+
Only Fairplay is supported.
|
|
368
|
+
|
|
369
|
+
The below is currently not fully supported by the iOS SDK, so please refer to `Example` app, or the [legacy DRM documentation](docs/legacy_readme.md#drm). For now, you must still provide the DRM asset in the `config.playlist` as a legacy object `[{fairplayCertUrl: string,processSpcUrl: string,file: string}]`
|
|
370
|
+
|
|
371
|
+
> Follow these steps to enable DRM:
|
|
372
|
+
> 1. Set up your iOS app for [DRM playback](https://developer.jwplayer.com/jwplayer/docs/ios-play-drm-protected-content).
|
|
373
|
+
> 2. Define `config.playlist` with the [JWP signed URL](https://docs.jwplayer.com/platform/docs/protection-studio-drm-generate-a-signed-content-url-for-drm-playback) of the media to play in the player.
|
|
374
|
+
>
|
|
375
|
+
> *❗️DO NOT sign and store your API secerets from your application.❗️*
|
|
376
|
+
>
|
|
377
|
+
If you use a different provider for DRM or this does not work for your use case, conforming to a similiar format as a JWP signed URL response is optimal, such as adding the `drm` field to the `sources` for a playlist item).
|
|
378
|
+
|
|
379
|
+
<br /><br />
|
|
380
|
+
|
|
381
|
+
### Picture in Picture (PiP)
|
|
382
|
+
|
|
383
|
+
[Android](#android-pip) | [iOS](#ios-pip)
|
|
384
|
+
|
|
385
|
+
#### Android PiP
|
|
386
|
+
|
|
387
|
+
1. Read and understand the requirements for PiP in the [Android SDK](https://docs.jwplayer.com/players/docs/android-invoke-picture-in-picture-playback).
|
|
388
|
+
2. In the activity where the player is embedded, add the following code.
|
|
389
|
+
```java
|
|
390
|
+
@Override
|
|
391
|
+
public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode, Configuration newConfig) {
|
|
392
|
+
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig);
|
|
393
|
+
|
|
394
|
+
Intent intent = new Intent("onPictureInPictureModeChanged");
|
|
395
|
+
intent.putExtra("isInPictureInPictureMode", isInPictureInPictureMode);
|
|
396
|
+
intent.putExtra("newConfig", newConfig);
|
|
397
|
+
this.sendBroadcast(intent);
|
|
398
|
+
}
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
<br />
|
|
402
|
+
|
|
403
|
+
#### iOS PiP
|
|
404
|
+
|
|
405
|
+
1. Read and understand the requirements for PiP in the [iOS SDK](https://docs.jwplayer.com/players/docs/ios-invoke-picture-in-picture-playback). PiP mode is enabled by JWP for the `PlayerViewController`.
|
|
406
|
+
2. (viewOnly:true only) Set the `pipEnabled` prop to `true`.
|
|
407
|
+
3. (viewOnly:true only) Call `togglePIP()` to enable or disable PiP.
|
|
408
|
+
|
|
409
|
+
<br /><br />
|
|
410
|
+
|
|
411
|
+
## Contributing
|
|
412
|
+
|
|
413
|
+
- All contributions should correlate to an open issue. We hope to avoid doubling the work between contributors.
|
|
414
|
+
- Changes shouldn't be a one-off solution for your use case.
|
|
415
|
+
- Keep work small as required. Large PRs aren't fun for anyone and will take longer to review.
|
|
416
|
+
|
|
417
|
+
<br /><br />
|
|
418
|
+
|
|
419
|
+
## Issues
|
|
420
|
+
|
|
421
|
+
- Follow the format for Bugs/Features/Questions.
|
|
422
|
+
- If submitting a bug, always attempt to recreate the issue in our Example app
|
|
423
|
+
- Provide as much relevant information as possible
|
|
424
|
+
- For the quickest support, reach out to JW support via this [link](https://support.jwplayer.com/hc/en-us/requests/new) after creating an issue on this repo. Providing the `Issue` number and additional, potentially proprietary/sensitive information.
|
|
425
|
+
|