Skip to content

Commit

Permalink
Release 1.10.4: Develop to main (#1387)
Browse files Browse the repository at this point in the history
# Description

- Release 1.10.4: Develop to main

### Pre-launch Checklist

- [x] The [Documentation] is updated accordingly, or this PR doesn't
require it.
- [x] I have updated the `ExampleAppChangelog.txt` file with relevant
changes.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I added new tests to check the change I am making, or this PR is
test-exempt.
- [x] All existing and new tests are passing.

<!-- Links -->

[Documentation]: https://www.100ms.live/docs
  • Loading branch information
stanwolverine authored Apr 26, 2024
2 parents 8c116b0 + 58c77b2 commit fbcd559
Show file tree
Hide file tree
Showing 75 changed files with 2,935 additions and 808 deletions.
4 changes: 2 additions & 2 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ lint:
- [email protected]
- [email protected]
- [email protected]
- [email protected].60
- [email protected].71
- [email protected]
- [email protected]
- [email protected]
Expand All @@ -26,7 +26,7 @@ lint:
- [email protected]
- git-diff-check
- [email protected]
- [email protected].0
- [email protected].1
runtimes:
enabled:
- [email protected]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,9 @@ object HMSDecoder {
variant.startedAt?.let {
input.putString("startedAt", it.toString())
}
variant.playlistType?.let {
input.putString("playlistType", it.name.uppercase())
}
variants.pushMap(input)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ package com.reactnativehmssdk
import android.annotation.SuppressLint
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.widget.FrameLayout
import androidx.media3.common.Player
import androidx.media3.common.VideoSize
import androidx.media3.common.text.CueGroup
import androidx.media3.ui.PlayerView
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.ReactContext
import com.facebook.react.bridge.ReadableArray
import com.facebook.react.bridge.ReadableMap
import com.facebook.react.bridge.WritableMap
import com.facebook.react.uimanager.events.RCTEventEmitter
import live.hms.hls_player.*
Expand All @@ -25,6 +29,7 @@ class HMSHLSPlayer(context: ReactContext) : FrameLayout(context) {
private var hmsHlsPlayer: HmsHlsPlayer? = null // 100ms HLS Player
private var hmssdkInstance: HMSSDK? = null
private var statsMonitorAttached = false
private var shouldSendCaptionsToJS = false
private val hmsHlsPlaybackEventsObject =
object : HmsHlsPlaybackEvents {
override fun onCue(cue: HmsHlsCue) {
Expand Down Expand Up @@ -115,6 +120,7 @@ class HMSHLSPlayer(context: ReactContext) : FrameLayout(context) {
val localPlayerView = view.findViewById<PlayerView>(R.id.hls_view)
playerView = localPlayerView
localPlayerView.useController = false
localPlayerView.subtitleView?.visibility = View.GONE

val hmssdkCollection = context.getNativeModule(HMSManager::class.java)?.getHmsInstance()
hmssdkInstance = hmssdkCollection?.get("12345")?.hmsSDK
Expand Down Expand Up @@ -144,6 +150,13 @@ class HMSHLSPlayer(context: ReactContext) : FrameLayout(context) {
sendHLSPlaybackEventToJS(HMSHLSPlayerConstants.ON_PLAYBACK_RESOLUTION_CHANGE_EVENT, data)
}
}

override fun onCues(cueGroup: CueGroup) {
super.onCues(cueGroup)
if (!shouldSendCaptionsToJS) return
val ccText = cueGroup.cues.firstOrNull()?.text?.toString()
sendHLSPlayerCuesEventToJS(ccText)
}
},
)
}
Expand Down Expand Up @@ -204,6 +217,38 @@ class HMSHLSPlayer(context: ReactContext) : FrameLayout(context) {
hmsHlsPlayer?.volume = level
}

fun areClosedCaptionSupported(requestId: Int) {
hmsHlsPlayer.let {
if (it == null) {
sendHLSDataRequestEventToJS(requestId, false)
} else {
sendHLSDataRequestEventToJS(requestId, it.areClosedCaptionsSupported())
}
}
}

fun isClosedCaptionEnabled(requestId: Int) {
sendHLSDataRequestEventToJS(requestId, shouldSendCaptionsToJS)
}

fun enableClosedCaption() {
shouldSendCaptionsToJS = true
}

fun disableClosedCaption() {
shouldSendCaptionsToJS = false
sendHLSPlayerCuesEventToJS(null)
}

fun getPlayerDurationDetails(requestId: Int) {
val data: WritableMap = Arguments.createMap()
hmsHlsPlayer?.getNativePlayer()?.let { exoPlayer ->
data.putInt("rollingWindowTime", exoPlayer.seekParameters.toleranceAfterUs.div(1000).toInt())
data.putInt("streamDuration", exoPlayer.duration.toInt())
}
sendHLSDataRequestEventToJS(requestId, data)
}

fun enableStats(enable: Boolean) {
if (enable) {
attachStatsMonitor()
Expand All @@ -215,11 +260,13 @@ class HMSHLSPlayer(context: ReactContext) : FrameLayout(context) {
fun enableControls(show: Boolean) {
playerView?.let {
if (show) {
it.subtitleView?.visibility = View.VISIBLE
it.useController = true
it.showController()
} else {
it.hideController()
it.useController = false
it.subtitleView?.visibility = View.GONE
}
}
}
Expand Down Expand Up @@ -263,6 +310,46 @@ class HMSHLSPlayer(context: ReactContext) : FrameLayout(context) {
val reactContext = context as ReactContext
reactContext.getJSModule(RCTEventEmitter::class.java).receiveEvent(id, HMSHLSPlayerConstants.HMS_HLS_STATS_EVENT, event)
}

private fun sendHLSDataRequestEventToJS(
requestId: Int,
data: Any,
) {
val event: WritableMap = Arguments.createMap()
event.putInt("requestId", requestId)

if (data is Boolean) {
event.putBoolean("data", data)
} else if (data is String) {
event.putString("data", data)
} else if (data is Int) {
event.putInt("data", data)
} else if (data is Double) {
event.putDouble("data", data)
} else if (data is ReadableMap) {
event.putMap("data", data)
} else if (data is ReadableArray) {
event.putArray("data", data)
} else {
event.putNull("data")
}

val reactContext = context as ReactContext
reactContext.getJSModule(RCTEventEmitter::class.java).receiveEvent(id, HMSHLSPlayerConstants.HLS_DATA_REQUEST_EVENT, event)
}

private fun sendHLSPlayerCuesEventToJS(ccText: String?) {
val event: WritableMap = Arguments.createMap()
event.putString("event", HMSHLSPlayerConstants.ON_CLOSED_CAPTION_UPDATE)

if (ccText is String) {
event.putString("data", ccText)
} else {
event.putNull("data")
}
val reactContext = context as ReactContext
reactContext.getJSModule(RCTEventEmitter::class.java).receiveEvent(id, HMSHLSPlayerConstants.HLS_PLAYER_CUES_EVENT, event)
}
}

object HMSHLSPlayerConstants {
Expand All @@ -277,4 +364,11 @@ object HMSHLSPlayerConstants {
const val HMS_HLS_STATS_EVENT = "hmsHlsStatsEvent"
const val ON_STATS_EVENT_UPDATE = "ON_STATS_EVENT_UPDATE"
const val ON_STATS_EVENT_ERROR = "ON_STATS_EVENT_ERROR"

// HLS Requested Data Returned
const val HLS_DATA_REQUEST_EVENT = "hlsDataRequestEvent"

// HLS Player Cues Events
const val HLS_PLAYER_CUES_EVENT = "hlsPlayerCuesEvent"
const val ON_CLOSED_CAPTION_UPDATE = "ON_CLOSED_CAPTION_UPDATE"
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class HMSHLSPlayerManager : SimpleViewManager<HMSHLSPlayer>() {
MapBuilder.of("registrationName", "onHmsHlsPlaybackEvent"),
HMSHLSPlayerConstants.HMS_HLS_STATS_EVENT,
MapBuilder.of("registrationName", "onHmsHlsStatsEvent"),
HMSHLSPlayerConstants.HLS_DATA_REQUEST_EVENT,
MapBuilder.of("registrationName", "onDataReturned"),
HMSHLSPlayerConstants.HLS_PLAYER_CUES_EVENT,
MapBuilder.of("registrationName", "onHlsPlayerCuesEvent"),
)
}

Expand Down Expand Up @@ -68,6 +72,29 @@ class HMSHLSPlayerManager : SimpleViewManager<HMSHLSPlayer>() {
}
}
}
90 -> {
args.let {
if (it != null) {
root.areClosedCaptionSupported(it.getInt(0))
}
}
}
100 -> {
args.let {
if (it != null) {
root.isClosedCaptionEnabled(it.getInt(0))
}
}
}
110 -> root.enableClosedCaption()
120 -> root.disableClosedCaption()
130 -> {
args.let {
if (it != null) {
root.getPlayerDurationDetails(it.getInt(0))
}
}
}
}
}

Expand All @@ -81,6 +108,11 @@ class HMSHLSPlayerManager : SimpleViewManager<HMSHLSPlayer>() {
.put("seekForward", 60)
.put("seekBackward", 70)
.put("setVolume", 80)
.put("areClosedCaptionSupported", 90)
.put("isClosedCaptionEnabled", 100)
.put("enableClosedCaption", 110)
.put("disableClosedCaption", 120)
.put("getPlayerDurationDetails", 130)
.build()
}

Expand Down
26 changes: 13 additions & 13 deletions packages/react-native-hms/example/android/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ GEM
artifactory (3.0.17)
atomos (0.1.3)
aws-eventstream (1.3.0)
aws-partitions (1.904.0)
aws-sdk-core (3.191.5)
aws-partitions (1.916.0)
aws-sdk-core (3.192.1)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.8)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.78.0)
aws-sdk-kms (1.79.0)
aws-sdk-core (~> 3, >= 3.191.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.146.1)
aws-sdk-core (~> 3, >= 3.191.0)
aws-sdk-s3 (1.147.0)
aws-sdk-core (~> 3, >= 3.192.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.8)
aws-sigv4 (1.8.0)
Expand Down Expand Up @@ -67,7 +67,7 @@ GEM
faraday-retry (1.0.3)
faraday_middleware (1.2.0)
faraday (~> 1.0)
fastimage (2.3.0)
fastimage (2.3.1)
fastlane (2.218.0)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
Expand Down Expand Up @@ -112,7 +112,7 @@ GEM
google-apis-firebaseappdistribution_v1 (~> 0.3.0)
google-apis-firebaseappdistribution_v1alpha (~> 0.2.0)
gh_inspector (1.1.3)
google-apis-androidpublisher_v3 (0.60.0)
google-apis-androidpublisher_v3 (0.62.0)
google-apis-core (>= 0.14.0, < 2.a)
google-apis-core (0.14.1)
addressable (~> 2.5, >= 2.5.1)
Expand All @@ -138,12 +138,12 @@ GEM
google-cloud-env (2.1.1)
faraday (>= 1.0, < 3.a)
google-cloud-errors (1.4.0)
google-cloud-storage (1.49.0)
google-cloud-storage (1.50.0)
addressable (~> 2.8)
digest-crc (~> 0.4)
google-apis-core (~> 0.13)
google-apis-iamcredentials_v1 (~> 0.18)
google-apis-storage_v1 (~> 0.33)
google-apis-storage_v1 (~> 0.37)
google-cloud-core (~> 1.6)
googleauth (~> 1.9)
mini_mime (~> 1.0)
Expand All @@ -159,7 +159,7 @@ GEM
domain_name (~> 0.5)
httpclient (2.8.3)
jmespath (1.6.2)
json (2.7.1)
json (2.7.2)
jwt (2.8.1)
base64
mini_magick (4.12.0)
Expand All @@ -169,11 +169,11 @@ GEM
nanaimo (0.3.0)
naturally (2.2.1)
nkf (0.2.0)
optparse (0.4.0)
optparse (0.5.0)
os (1.1.4)
plist (3.7.1)
public_suffix (5.0.4)
rake (13.1.0)
public_suffix (5.0.5)
rake (13.2.1)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
Expand Down
26 changes: 13 additions & 13 deletions packages/react-native-hms/example/ios/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ GEM
artifactory (3.0.17)
atomos (0.1.3)
aws-eventstream (1.3.0)
aws-partitions (1.904.0)
aws-sdk-core (3.191.5)
aws-partitions (1.916.0)
aws-sdk-core (3.192.1)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.8)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.78.0)
aws-sdk-kms (1.79.0)
aws-sdk-core (~> 3, >= 3.191.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.146.1)
aws-sdk-core (~> 3, >= 3.191.0)
aws-sdk-s3 (1.147.0)
aws-sdk-core (~> 3, >= 3.192.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.8)
aws-sigv4 (1.8.0)
Expand Down Expand Up @@ -67,7 +67,7 @@ GEM
faraday-retry (1.0.3)
faraday_middleware (1.2.0)
faraday (~> 1.0)
fastimage (2.3.0)
fastimage (2.3.1)
fastlane (2.218.0)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
Expand Down Expand Up @@ -109,7 +109,7 @@ GEM
xcpretty (~> 0.3.0)
xcpretty-travis-formatter (>= 0.0.3)
gh_inspector (1.1.3)
google-apis-androidpublisher_v3 (0.60.0)
google-apis-androidpublisher_v3 (0.62.0)
google-apis-core (>= 0.14.0, < 2.a)
google-apis-core (0.14.1)
addressable (~> 2.5, >= 2.5.1)
Expand All @@ -131,12 +131,12 @@ GEM
google-cloud-env (2.1.1)
faraday (>= 1.0, < 3.a)
google-cloud-errors (1.4.0)
google-cloud-storage (1.49.0)
google-cloud-storage (1.50.0)
addressable (~> 2.8)
digest-crc (~> 0.4)
google-apis-core (~> 0.13)
google-apis-iamcredentials_v1 (~> 0.18)
google-apis-storage_v1 (~> 0.33)
google-apis-storage_v1 (~> 0.37)
google-cloud-core (~> 1.6)
googleauth (~> 1.9)
mini_mime (~> 1.0)
Expand All @@ -152,7 +152,7 @@ GEM
domain_name (~> 0.5)
httpclient (2.8.3)
jmespath (1.6.2)
json (2.7.1)
json (2.7.2)
jwt (2.8.1)
base64
mini_magick (4.12.0)
Expand All @@ -162,11 +162,11 @@ GEM
nanaimo (0.3.0)
naturally (2.2.1)
nkf (0.2.0)
optparse (0.4.0)
optparse (0.5.0)
os (1.1.4)
plist (3.7.1)
public_suffix (5.0.4)
rake (13.1.0)
public_suffix (5.0.5)
rake (13.2.1)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
Expand Down
Loading

0 comments on commit fbcd559

Please sign in to comment.