Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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 com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.LifecycleEventListener
import com.facebook.react.bridge.ReactContext
Expand Down Expand Up @@ -314,7 +315,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 @@ -325,7 +326,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 @@ -346,8 +347,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 @@ -418,7 +421,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 @@ -430,11 +433,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