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

RN 0.73 support #158

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ def pkgData = new JsonSlurper().parseText(rootPkg.text)
def sdk_version = pkgData.version

android {
namespace = "com.amazonaws.ivs.reactnative.player"
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
buildToolsVersion getExtOrDefault('buildToolsVersion')
defaultConfig {
minSdkVersion 21
minSdkVersion 26
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
versionCode 1
versionName sdk_version
Expand Down
3 changes: 1 addition & 2 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.amazonaws.ivs.reactnative.player">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" >
<application>
<meta-data
android:name="com.amazonaws.ivs.player.FRAMEWORK_NAME"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.net.Uri
import android.widget.FrameLayout
import com.amazonaws.ivs.player.*
import android.os.Build
import com.amazonaws.ivs.player.Player.State.*
import android.util.Log
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.LifecycleEventListener
Expand Down Expand Up @@ -352,7 +353,7 @@ class AmazonIvsView(private val context: ThemedReactContext) : FrameLayout(conte
val reactContext = context as ReactContext

when (state) {
Player.State.PLAYING -> {
PLAYING -> {
if (!finishedLoading) {
val onLoadData = Arguments.createMap()
val parsedDuration = getDuration(player!!.duration);
Expand All @@ -363,7 +364,7 @@ class AmazonIvsView(private val context: ThemedReactContext) : FrameLayout(conte
reactContext.getJSModule(RCTEventEmitter::class.java).receiveEvent(id, Events.LOAD.toString(), onLoadData)
}
}
Player.State.READY -> {
READY -> {
val data = Arguments.createMap()
val playerData = Arguments.createMap()
playerData.putString("version", player?.version)
Expand All @@ -384,8 +385,10 @@ class AmazonIvsView(private val context: ThemedReactContext) : FrameLayout(conte
data.putMap("playerData", playerData)

reactContext.getJSModule(RCTEventEmitter::class.java).receiveEvent(id, Events.DATA.toString(), data)
}
else -> {}
};
BUFFERING -> {} // The following empty statements are intentional and avoid Kotlin’s "expression must be exhaustive" error.
IDLE -> {}
ENDED -> {}
}

val onStateChangeData = Arguments.createMap()
Expand Down Expand Up @@ -467,7 +470,7 @@ class AmazonIvsView(private val context: ThemedReactContext) : FrameLayout(conte
lastDuration = player?.duration
}
player?.position?.let { position ->
if (position > 0 && player?.state === Player.State.PLAYING) {
if (position > 0 && player?.state === PLAYING) {
onProgress(position)
}
}
Expand All @@ -479,11 +482,11 @@ class AmazonIvsView(private val context: ThemedReactContext) : FrameLayout(conte

private fun mapPlayerState(state: Player.State): String {
return when(state) {
Player.State.PLAYING -> "Playing"
Player.State.BUFFERING -> "Buffering"
Player.State.READY -> "Ready"
Player.State.IDLE -> "Idle"
Player.State.ENDED -> "Ended"
PLAYING -> "Playing"
BUFFERING -> "Buffering"
READY -> "Ready"
IDLE -> "Idle"
ENDED -> "Ended"
}
}

Expand Down
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
buildscript {
ext {
buildToolsVersion = "31.0.0"
minSdkVersion = 21
minSdkVersion = 26
compileSdkVersion = 31
targetSdkVersion = 31
kotlin_version = '1.6.0'
Expand Down