bitmovin-player-react-native 0.6.0 → 0.7.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.
Files changed (31) hide show
  1. package/README.md +23 -906
  2. package/RNBitmovinPlayer.podspec +2 -2
  3. package/android/build.gradle +5 -4
  4. package/android/gradle.properties +1 -0
  5. package/android/gradlew +244 -0
  6. package/android/gradlew.bat +92 -0
  7. package/android/src/main/java/com/bitmovin/player/reactnative/RNPlayerViewManager.kt +36 -7
  8. package/android/src/main/java/com/bitmovin/player/reactnative/RNPlayerViewPackage.kt +3 -1
  9. package/android/src/main/java/com/bitmovin/player/reactnative/converter/JsonConverter.kt +7 -1
  10. package/android/src/main/java/com/bitmovin/player/reactnative/extensions/ReadableMap.kt +19 -0
  11. package/android/src/main/java/com/bitmovin/player/reactnative/extensions/ReadableMapExtension.kt +7 -0
  12. package/android/src/main/java/com/bitmovin/player/reactnative/ui/CustomMessageHandlerBridge.kt +37 -0
  13. package/android/src/main/java/com/bitmovin/player/reactnative/ui/CustomMessageHandlerModule.kt +86 -0
  14. package/ios/CustomMessageHandlerBridge.swift +50 -0
  15. package/ios/CustomMessageHandlerModule.m +10 -0
  16. package/ios/CustomMessageHandlerModule.swift +83 -0
  17. package/ios/RCTBridge+Generics.swift +6 -0
  18. package/ios/RCTConvert+BitmovinPlayer.swift +3 -0
  19. package/ios/RNPlayerViewManager.m +1 -0
  20. package/ios/RNPlayerViewManager.swift +19 -1
  21. package/lib/index.d.ts +46 -2
  22. package/lib/index.js +111 -20
  23. package/lib/index.mjs +98 -8
  24. package/package.json +5 -2
  25. package/src/components/PlayerView/index.tsx +29 -1
  26. package/src/components/PlayerView/native.ts +2 -0
  27. package/src/source.ts +4 -0
  28. package/src/ui/custommessagehandler.ts +68 -0
  29. package/src/ui/custommessagehandlerbridge.ts +72 -0
  30. package/src/ui/custommessagesender.ts +3 -0
  31. package/src/ui/index.ts +1 -0
@@ -10,7 +10,7 @@ Pod::Spec.new do |s|
10
10
  s.license = package["license"]
11
11
  s.authors = package["author"]
12
12
 
13
- s.platforms = { :ios => "12.4", :tvos => "12.4" }
13
+ s.platforms = { :ios => "14.0", :tvos => "14.0" }
14
14
  s.source = {
15
15
  :git => "https://github.com/bitmovin/bitmovin-player-react-native.git",
16
16
  :tag => "v#{s.version}"
@@ -19,7 +19,7 @@ Pod::Spec.new do |s|
19
19
  s.source_files = "ios/**/*.{h,m,mm,swift}"
20
20
 
21
21
  s.dependency "React-Core"
22
- s.dependency "BitmovinPlayer", "3.36.0"
22
+ s.dependency "BitmovinPlayer", "3.41.0"
23
23
  s.dependency "BitmovinAnalyticsCollector/Core", "2.9.4"
24
24
  s.dependency "BitmovinAnalyticsCollector/BitmovinPlayer", "2.9.4"
25
25
  s.ios.dependency "GoogleAds-IMA-iOS-SDK", "3.17.0"
@@ -1,7 +1,7 @@
1
1
  buildscript {
2
2
  ext {
3
3
  kotlinVersion = '1.7.21'
4
- androidToolsVersion = '7.0.4'
4
+ androidToolsVersion = '7.4.2'
5
5
  }
6
6
  repositories {
7
7
  google()
@@ -24,12 +24,13 @@ repositories {
24
24
  }
25
25
  google()
26
26
  mavenCentral()
27
+ maven { url 'https://artifacts.bitmovin.com/artifactory/public-releases' }
27
28
  }
28
29
 
29
30
  android {
30
31
  compileSdk 33
31
32
  defaultConfig {
32
- minSdkVersion 16
33
+ minSdkVersion 21
33
34
  targetSdkVersion 33
34
35
  versionCode 1
35
36
  versionName '1.0'
@@ -53,6 +54,6 @@ dependencies {
53
54
  implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.26.0'
54
55
  implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
55
56
  implementation 'com.bitmovin.analytics:collector-bitmovin-player:2.12.1'
56
- implementation 'com.bitmovin.player:player:3.35.0'
57
- implementation 'com.facebook.react:react-native:+'
57
+ implementation 'com.bitmovin.player:player:3.39.0'
58
+ implementation 'com.facebook.react:react-native:0.69.10'
58
59
  }
@@ -0,0 +1 @@
1
+ android.useAndroidX=true
@@ -0,0 +1,244 @@
1
+ #!/bin/sh
2
+
3
+ #
4
+ # Copyright © 2015-2021 the original authors.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ ##############################################################################
20
+ #
21
+ # Gradle start up script for POSIX generated by Gradle.
22
+ #
23
+ # Important for running:
24
+ #
25
+ # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26
+ # noncompliant, but you have some other compliant shell such as ksh or
27
+ # bash, then to run this script, type that shell name before the whole
28
+ # command line, like:
29
+ #
30
+ # ksh Gradle
31
+ #
32
+ # Busybox and similar reduced shells will NOT work, because this script
33
+ # requires all of these POSIX shell features:
34
+ # * functions;
35
+ # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36
+ # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37
+ # * compound commands having a testable exit status, especially «case»;
38
+ # * various built-in commands including «command», «set», and «ulimit».
39
+ #
40
+ # Important for patching:
41
+ #
42
+ # (2) This script targets any POSIX shell, so it avoids extensions provided
43
+ # by Bash, Ksh, etc; in particular arrays are avoided.
44
+ #
45
+ # The "traditional" practice of packing multiple parameters into a
46
+ # space-separated string is a well documented source of bugs and security
47
+ # problems, so this is (mostly) avoided, by progressively accumulating
48
+ # options in "$@", and eventually passing that to Java.
49
+ #
50
+ # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51
+ # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52
+ # see the in-line comments for details.
53
+ #
54
+ # There are tweaks for specific operating systems such as AIX, CygWin,
55
+ # Darwin, MinGW, and NonStop.
56
+ #
57
+ # (3) This script is generated from the Groovy template
58
+ # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59
+ # within the Gradle project.
60
+ #
61
+ # You can find Gradle at https://github.com/gradle/gradle/.
62
+ #
63
+ ##############################################################################
64
+
65
+ # Attempt to set APP_HOME
66
+
67
+ # Resolve links: $0 may be a link
68
+ app_path=$0
69
+
70
+ # Need this for daisy-chained symlinks.
71
+ while
72
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73
+ [ -h "$app_path" ]
74
+ do
75
+ ls=$( ls -ld "$app_path" )
76
+ link=${ls#*' -> '}
77
+ case $link in #(
78
+ /*) app_path=$link ;; #(
79
+ *) app_path=$APP_HOME$link ;;
80
+ esac
81
+ done
82
+
83
+ # This is normally unused
84
+ # shellcheck disable=SC2034
85
+ APP_BASE_NAME=${0##*/}
86
+ APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
87
+
88
+ # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89
+ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
90
+
91
+ # Use the maximum available, or set MAX_FD != -1 to use that value.
92
+ MAX_FD=maximum
93
+
94
+ warn () {
95
+ echo "$*"
96
+ } >&2
97
+
98
+ die () {
99
+ echo
100
+ echo "$*"
101
+ echo
102
+ exit 1
103
+ } >&2
104
+
105
+ # OS specific support (must be 'true' or 'false').
106
+ cygwin=false
107
+ msys=false
108
+ darwin=false
109
+ nonstop=false
110
+ case "$( uname )" in #(
111
+ CYGWIN* ) cygwin=true ;; #(
112
+ Darwin* ) darwin=true ;; #(
113
+ MSYS* | MINGW* ) msys=true ;; #(
114
+ NONSTOP* ) nonstop=true ;;
115
+ esac
116
+
117
+ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118
+
119
+
120
+ # Determine the Java command to use to start the JVM.
121
+ if [ -n "$JAVA_HOME" ] ; then
122
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123
+ # IBM's JDK on AIX uses strange locations for the executables
124
+ JAVACMD=$JAVA_HOME/jre/sh/java
125
+ else
126
+ JAVACMD=$JAVA_HOME/bin/java
127
+ fi
128
+ if [ ! -x "$JAVACMD" ] ; then
129
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130
+
131
+ Please set the JAVA_HOME variable in your environment to match the
132
+ location of your Java installation."
133
+ fi
134
+ else
135
+ JAVACMD=java
136
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137
+
138
+ Please set the JAVA_HOME variable in your environment to match the
139
+ location of your Java installation."
140
+ fi
141
+
142
+ # Increase the maximum file descriptors if we can.
143
+ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144
+ case $MAX_FD in #(
145
+ max*)
146
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
147
+ # shellcheck disable=SC3045
148
+ MAX_FD=$( ulimit -H -n ) ||
149
+ warn "Could not query maximum file descriptor limit"
150
+ esac
151
+ case $MAX_FD in #(
152
+ '' | soft) :;; #(
153
+ *)
154
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
155
+ # shellcheck disable=SC3045
156
+ ulimit -n "$MAX_FD" ||
157
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
158
+ esac
159
+ fi
160
+
161
+ # Collect all arguments for the java command, stacking in reverse order:
162
+ # * args from the command line
163
+ # * the main class name
164
+ # * -classpath
165
+ # * -D...appname settings
166
+ # * --module-path (only if needed)
167
+ # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
168
+
169
+ # For Cygwin or MSYS, switch paths to Windows format before running java
170
+ if "$cygwin" || "$msys" ; then
171
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
172
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
173
+
174
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
175
+
176
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
177
+ for arg do
178
+ if
179
+ case $arg in #(
180
+ -*) false ;; # don't mess with options #(
181
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
182
+ [ -e "$t" ] ;; #(
183
+ *) false ;;
184
+ esac
185
+ then
186
+ arg=$( cygpath --path --ignore --mixed "$arg" )
187
+ fi
188
+ # Roll the args list around exactly as many times as the number of
189
+ # args, so each arg winds up back in the position where it started, but
190
+ # possibly modified.
191
+ #
192
+ # NB: a `for` loop captures its iteration list before it begins, so
193
+ # changing the positional parameters here affects neither the number of
194
+ # iterations, nor the values presented in `arg`.
195
+ shift # remove old arg
196
+ set -- "$@" "$arg" # push replacement arg
197
+ done
198
+ fi
199
+
200
+ # Collect all arguments for the java command;
201
+ # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
202
+ # shell script including quotes and variable substitutions, so put them in
203
+ # double quotes to make sure that they get re-expanded; and
204
+ # * put everything else in single quotes, so that it's not re-expanded.
205
+
206
+ set -- \
207
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
208
+ -classpath "$CLASSPATH" \
209
+ org.gradle.wrapper.GradleWrapperMain \
210
+ "$@"
211
+
212
+ # Stop when "xargs" is not available.
213
+ if ! command -v xargs >/dev/null 2>&1
214
+ then
215
+ die "xargs is not available"
216
+ fi
217
+
218
+ # Use "xargs" to parse quoted args.
219
+ #
220
+ # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
221
+ #
222
+ # In Bash we could simply go:
223
+ #
224
+ # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
225
+ # set -- "${ARGS[@]}" "$@"
226
+ #
227
+ # but POSIX shell has neither arrays nor command substitution, so instead we
228
+ # post-process each arg (as a line of input to sed) to backslash-escape any
229
+ # character that might be a shell metacharacter, then use eval to reverse
230
+ # that process (while maintaining the separation between arguments), and wrap
231
+ # the whole thing up as a single "set" statement.
232
+ #
233
+ # This will of course break if any of these variables contains a newline or
234
+ # an unmatched quote.
235
+ #
236
+
237
+ eval "set -- $(
238
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
239
+ xargs -n1 |
240
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
241
+ tr '\n' ' '
242
+ )" '"$@"'
243
+
244
+ exec "$JAVACMD" "$@"
@@ -0,0 +1,92 @@
1
+ @rem
2
+ @rem Copyright 2015 the original author or authors.
3
+ @rem
4
+ @rem Licensed under the Apache License, Version 2.0 (the "License");
5
+ @rem you may not use this file except in compliance with the License.
6
+ @rem You may obtain a copy of the License at
7
+ @rem
8
+ @rem https://www.apache.org/licenses/LICENSE-2.0
9
+ @rem
10
+ @rem Unless required by applicable law or agreed to in writing, software
11
+ @rem distributed under the License is distributed on an "AS IS" BASIS,
12
+ @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ @rem See the License for the specific language governing permissions and
14
+ @rem limitations under the License.
15
+ @rem
16
+
17
+ @if "%DEBUG%"=="" @echo off
18
+ @rem ##########################################################################
19
+ @rem
20
+ @rem Gradle startup script for Windows
21
+ @rem
22
+ @rem ##########################################################################
23
+
24
+ @rem Set local scope for the variables with windows NT shell
25
+ if "%OS%"=="Windows_NT" setlocal
26
+
27
+ set DIRNAME=%~dp0
28
+ if "%DIRNAME%"=="" set DIRNAME=.
29
+ @rem This is normally unused
30
+ set APP_BASE_NAME=%~n0
31
+ set APP_HOME=%DIRNAME%
32
+
33
+ @rem Resolve any "." and ".." in APP_HOME to make it shorter.
34
+ for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
35
+
36
+ @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
37
+ set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
38
+
39
+ @rem Find java.exe
40
+ if defined JAVA_HOME goto findJavaFromJavaHome
41
+
42
+ set JAVA_EXE=java.exe
43
+ %JAVA_EXE% -version >NUL 2>&1
44
+ if %ERRORLEVEL% equ 0 goto execute
45
+
46
+ echo.
47
+ echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
48
+ echo.
49
+ echo Please set the JAVA_HOME variable in your environment to match the
50
+ echo location of your Java installation.
51
+
52
+ goto fail
53
+
54
+ :findJavaFromJavaHome
55
+ set JAVA_HOME=%JAVA_HOME:"=%
56
+ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
57
+
58
+ if exist "%JAVA_EXE%" goto execute
59
+
60
+ echo.
61
+ echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
62
+ echo.
63
+ echo Please set the JAVA_HOME variable in your environment to match the
64
+ echo location of your Java installation.
65
+
66
+ goto fail
67
+
68
+ :execute
69
+ @rem Setup the command line
70
+
71
+ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
72
+
73
+
74
+ @rem Execute Gradle
75
+ "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
76
+
77
+ :end
78
+ @rem End local scope for the variables with windows NT shell
79
+ if %ERRORLEVEL% equ 0 goto mainEnd
80
+
81
+ :fail
82
+ rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83
+ rem the _cmd.exe /c_ return code!
84
+ set EXIT_CODE=%ERRORLEVEL%
85
+ if %EXIT_CODE% equ 0 set EXIT_CODE=1
86
+ if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
87
+ exit /b %EXIT_CODE%
88
+
89
+ :mainEnd
90
+ if "%OS%"=="Windows_NT" endlocal
91
+
92
+ :omega
@@ -4,11 +4,14 @@ import android.os.Handler
4
4
  import android.os.Looper
5
5
  import android.view.ViewGroup.LayoutParams
6
6
  import com.bitmovin.player.PlayerView
7
+ import com.bitmovin.player.reactnative.extensions.getBooleanOrNull
7
8
  import com.bitmovin.player.reactnative.extensions.getModule
8
- import com.bitmovin.player.reactnative.ui.FullscreenHandlerBridge
9
+ import com.bitmovin.player.reactnative.ui.CustomMessageHandlerModule
9
10
  import com.bitmovin.player.reactnative.ui.FullscreenHandlerModule
10
11
  import com.bitmovin.player.reactnative.ui.RNPictureInPictureHandler
11
- import com.facebook.react.bridge.*
12
+ import com.facebook.react.bridge.ReactApplicationContext
13
+ import com.facebook.react.bridge.ReadableArray
14
+ import com.facebook.react.bridge.ReadableMap
12
15
  import com.facebook.react.module.annotations.ReactModule
13
16
  import com.facebook.react.uimanager.SimpleViewManager
14
17
  import com.facebook.react.uimanager.ThemedReactContext
@@ -22,7 +25,8 @@ class RNPlayerViewManager(private val context: ReactApplicationContext) : Simple
22
25
  */
23
26
  enum class Commands {
24
27
  ATTACH_PLAYER,
25
- ATTACH_FULLSCREEN_BRIDGE
28
+ ATTACH_FULLSCREEN_BRIDGE,
29
+ SET_CUSTOM_MESSAGE_HANDLER_BRIDGE_ID,
26
30
  }
27
31
 
28
32
  /**
@@ -30,6 +34,8 @@ class RNPlayerViewManager(private val context: ReactApplicationContext) : Simple
30
34
  */
31
35
  override fun getName() = MODULE_NAME
32
36
 
37
+ private var customMessageHandlerBridgeId: NativeId? = null
38
+
33
39
  /**
34
40
  * React Native PiP handler instance. It can be subclassed, then set from other native
35
41
  * modules in case a full-custom implementation is needed. A default implementation is provided
@@ -126,6 +132,7 @@ class RNPlayerViewManager(private val context: ReactApplicationContext) : Simple
126
132
  override fun getCommandsMap(): MutableMap<String, Int> = mutableMapOf(
127
133
  "attachPlayer" to Commands.ATTACH_PLAYER.ordinal,
128
134
  "attachFullscreenBridge" to Commands.ATTACH_FULLSCREEN_BRIDGE.ordinal,
135
+ "setCustomMessageHandlerBridgeId" to Commands.SET_CUSTOM_MESSAGE_HANDLER_BRIDGE_ID.ordinal,
129
136
  )
130
137
 
131
138
  /**
@@ -142,6 +149,11 @@ class RNPlayerViewManager(private val context: ReactApplicationContext) : Simple
142
149
  Commands.ATTACH_FULLSCREEN_BRIDGE.ordinal -> args?.getString(1)?.let { fullscreenBridgeId ->
143
150
  attachFullscreenBridge(view, fullscreenBridgeId)
144
151
  }
152
+ Commands.SET_CUSTOM_MESSAGE_HANDLER_BRIDGE_ID.ordinal -> {
153
+ args?.getString(1)?.let { customMessageHandlerBridgeId ->
154
+ setCustomMessageHandlerBridgeId(view, customMessageHandlerBridgeId)
155
+ }
156
+ }
145
157
  else -> {}
146
158
  }
147
159
  }
@@ -155,6 +167,19 @@ class RNPlayerViewManager(private val context: ReactApplicationContext) : Simple
155
167
  }
156
168
  }
157
169
 
170
+ private fun setCustomMessageHandlerBridgeId(view: RNPlayerView, customMessageHandlerBridgeId: NativeId) {
171
+ this.customMessageHandlerBridgeId = customMessageHandlerBridgeId
172
+ attachCustomMessageHandlerBridge(view)
173
+ }
174
+
175
+ private fun attachCustomMessageHandlerBridge(view: RNPlayerView) {
176
+ view.playerView?.setCustomMessageHandler(
177
+ context.getModule<CustomMessageHandlerModule>()
178
+ ?.getInstance(customMessageHandlerBridgeId)
179
+ ?.customMessageHandler
180
+ )
181
+ }
182
+
158
183
  /**
159
184
  * Set the `Player` instance for the target view using `playerId`.
160
185
  * @param view Target `RNPlayerView`.
@@ -163,10 +188,13 @@ class RNPlayerViewManager(private val context: ReactApplicationContext) : Simple
163
188
  private fun attachPlayer(view: RNPlayerView, playerId: NativeId?, playerConfig: ReadableMap?) {
164
189
  Handler(Looper.getMainLooper()).post {
165
190
  val player = getPlayerModule()?.getPlayer(playerId)
166
- playerConfig?.getMap("playbackConfig")?.getBoolean("isPictureInPictureEnabled")?.let {
167
- pictureInPictureHandler.isPictureInPictureEnabled = it
168
- view.pictureInPictureHandler = pictureInPictureHandler
169
- }
191
+ playerConfig
192
+ ?.getMap("playbackConfig")
193
+ ?.getBooleanOrNull("isPictureInPictureEnabled")
194
+ ?.let {
195
+ pictureInPictureHandler.isPictureInPictureEnabled = it
196
+ view.pictureInPictureHandler = pictureInPictureHandler
197
+ }
170
198
  if (view.playerView != null) {
171
199
  view.player = player
172
200
  } else {
@@ -176,6 +204,7 @@ class RNPlayerViewManager(private val context: ReactApplicationContext) : Simple
176
204
  LayoutParams.MATCH_PARENT
177
205
  )
178
206
  view.addPlayerView(playerView)
207
+ attachCustomMessageHandlerBridge(view)
179
208
  }
180
209
  }
181
210
  }
@@ -1,6 +1,7 @@
1
1
  package com.bitmovin.player.reactnative
2
2
 
3
3
  import android.view.View
4
+ import com.bitmovin.player.reactnative.ui.CustomMessageHandlerModule
4
5
  import com.bitmovin.player.reactnative.ui.FullscreenHandlerModule
5
6
  import com.facebook.react.ReactPackage
6
7
  import com.facebook.react.bridge.NativeModule
@@ -24,7 +25,8 @@ class RNPlayerViewPackage : ReactPackage {
24
25
  DrmModule(reactContext),
25
26
  AnalyticsModule(reactContext),
26
27
  RNPlayerViewManager(reactContext),
27
- FullscreenHandlerModule(reactContext)
28
+ FullscreenHandlerModule(reactContext),
29
+ CustomMessageHandlerModule(reactContext)
28
30
  )
29
31
  }
30
32
 
@@ -29,6 +29,7 @@ import com.bitmovin.player.reactnative.extensions.toReadableArray
29
29
  import com.bitmovin.player.reactnative.extensions.getProperty
30
30
  import com.bitmovin.player.reactnative.extensions.setProperty
31
31
  import com.facebook.react.bridge.*
32
+ import com.bitmovin.player.reactnative.extensions.toReadableMap
32
33
  import java.util.UUID
33
34
 
34
35
  /**
@@ -265,6 +266,11 @@ class JsonConverter {
265
266
  if (json.hasKey("thumbnailTrack")) {
266
267
  config.thumbnailTrack = toThumbnailTrack(json.getString("thumbnailTrack"))
267
268
  }
269
+ if (json.hasKey("metadata")) {
270
+ config.metadata = json.getMap("metadata")
271
+ ?.toHashMap()
272
+ ?.mapValues { entry -> entry.value as String }
273
+ }
268
274
  return config
269
275
  }
270
276
 
@@ -297,7 +303,7 @@ class JsonConverter {
297
303
  json.putBoolean("isActive", source.isActive)
298
304
  json.putBoolean("isAttachedToPlayer", source.isAttachedToPlayer)
299
305
  json.putInt("loadingState", source.loadingState.ordinal)
300
- json.putNull("metadata")
306
+ json.putMap("metadata", source.config.metadata?.toReadableMap())
301
307
  return json
302
308
  }
303
309
 
@@ -0,0 +1,19 @@
1
+ package com.bitmovin.player.reactnative.extensions
2
+
3
+ import com.facebook.react.bridge.*
4
+
5
+ inline fun <reified T> Map<String, T>.toReadableMap(): ReadableMap = Arguments.createMap().apply {
6
+ forEach {
7
+ when (T::class) {
8
+ Boolean::class -> putBoolean(it.key, it.value as Boolean)
9
+ String::class -> putString(it.key, it.value as String)
10
+ Double::class -> putDouble(it.key, it.value as Double)
11
+ Int::class -> putInt(it.key, it.value as Int)
12
+ ReadableArray::class -> putArray(it.key, it.value as ReadableArray)
13
+ ReadableMap::class -> putMap(it.key, it.value as ReadableMap)
14
+ WritableArray::class -> putArray(it.key, it.value as ReadableArray)
15
+ WritableMap::class -> putMap(it.key, it.value as ReadableMap)
16
+ else -> putNull(it.key)
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,7 @@
1
+ package com.bitmovin.player.reactnative.extensions
2
+
3
+ import com.facebook.react.bridge.ReadableMap
4
+
5
+ fun ReadableMap.getBooleanOrNull(
6
+ key: String
7
+ ): Boolean? = takeIf { hasKey(key) }?.getBoolean(key)
@@ -0,0 +1,37 @@
1
+ package com.bitmovin.player.reactnative.ui
2
+
3
+ import android.webkit.JavascriptInterface
4
+ import com.bitmovin.player.reactnative.NativeId
5
+ import com.bitmovin.player.reactnative.extensions.getModule
6
+ import com.bitmovin.player.ui.CustomMessageHandler
7
+ import com.facebook.react.bridge.ReactApplicationContext
8
+
9
+ class CustomMessageHandlerBridge(
10
+ val context: ReactApplicationContext,
11
+ private val nativeId: NativeId
12
+ ) {
13
+ val customMessageHandler = CustomMessageHandler(object: Any() {
14
+ @JavascriptInterface
15
+ fun sendSynchronous(name: String, data: String?): String? = context
16
+ .getModule<CustomMessageHandlerModule>()
17
+ ?.receivedSynchronousMessage(nativeId, name, data)
18
+
19
+ @JavascriptInterface
20
+ fun sendAsynchronous(name: String, data: String?) = context
21
+ .getModule<CustomMessageHandlerModule>()
22
+ ?.receivedAsynchronousMessage(nativeId, name, data)
23
+ })
24
+
25
+ private var currentSynchronousResult: String? = null
26
+
27
+ fun sendMessage(message: String, data: String?) = customMessageHandler.sendMessage(message, data)
28
+
29
+ fun popSynchronousResult(): String? = currentSynchronousResult?.let {
30
+ currentSynchronousResult = null
31
+ return it
32
+ }
33
+
34
+ fun pushSynchronousResult(result: String?) {
35
+ currentSynchronousResult = result
36
+ }
37
+ }