feat(android): allow chunckless preparation (#3882)
* feat(android): add a way to disable chuncklessPreparation on HLS
This commit is contained in:
parent
ac0a9c3e3a
commit
d4a8c24f65
@ -9,6 +9,7 @@ import android.text.TextUtils
|
|||||||
import com.brentvatne.common.toolbox.DebugLog
|
import com.brentvatne.common.toolbox.DebugLog
|
||||||
import com.brentvatne.common.toolbox.DebugLog.e
|
import com.brentvatne.common.toolbox.DebugLog.e
|
||||||
import com.brentvatne.common.toolbox.ReactBridgeUtils.safeGetArray
|
import com.brentvatne.common.toolbox.ReactBridgeUtils.safeGetArray
|
||||||
|
import com.brentvatne.common.toolbox.ReactBridgeUtils.safeGetBool
|
||||||
import com.brentvatne.common.toolbox.ReactBridgeUtils.safeGetInt
|
import com.brentvatne.common.toolbox.ReactBridgeUtils.safeGetInt
|
||||||
import com.brentvatne.common.toolbox.ReactBridgeUtils.safeGetMap
|
import com.brentvatne.common.toolbox.ReactBridgeUtils.safeGetMap
|
||||||
import com.brentvatne.common.toolbox.ReactBridgeUtils.safeGetString
|
import com.brentvatne.common.toolbox.ReactBridgeUtils.safeGetString
|
||||||
@ -44,6 +45,11 @@ class Source {
|
|||||||
/** http header list */
|
/** http header list */
|
||||||
val headers: MutableMap<String, String> = HashMap()
|
val headers: MutableMap<String, String> = HashMap()
|
||||||
|
|
||||||
|
/** enable chunckless preparation for HLS
|
||||||
|
* see:
|
||||||
|
*/
|
||||||
|
var textTracksAllowChuncklessPreparation: Boolean = false
|
||||||
|
|
||||||
/** return true if this and src are equals */
|
/** return true if this and src are equals */
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
if (other == null || other !is Source) return false
|
if (other == null || other !is Source) return false
|
||||||
@ -114,6 +120,7 @@ class Source {
|
|||||||
private const val PROP_SRC_TYPE = "type"
|
private const val PROP_SRC_TYPE = "type"
|
||||||
private const val PROP_SRC_METADATA = "metadata"
|
private const val PROP_SRC_METADATA = "metadata"
|
||||||
private const val PROP_SRC_HEADERS = "requestHeaders"
|
private const val PROP_SRC_HEADERS = "requestHeaders"
|
||||||
|
private const val PROP_SRC_TEXT_TRACKS_ALLOW_CHUNCKLESS_PREPARATION = "textTracksAllowChunklessPreparation"
|
||||||
|
|
||||||
@SuppressLint("DiscouragedApi")
|
@SuppressLint("DiscouragedApi")
|
||||||
private fun getUriFromAssetId(context: Context, uriString: String): Uri? {
|
private fun getUriFromAssetId(context: Context, uriString: String): Uri? {
|
||||||
@ -170,6 +177,7 @@ class Source {
|
|||||||
source.cropStartMs = safeGetInt(src, PROP_SRC_CROP_START, -1)
|
source.cropStartMs = safeGetInt(src, PROP_SRC_CROP_START, -1)
|
||||||
source.cropEndMs = safeGetInt(src, PROP_SRC_CROP_END, -1)
|
source.cropEndMs = safeGetInt(src, PROP_SRC_CROP_END, -1)
|
||||||
source.extension = safeGetString(src, PROP_SRC_TYPE, null)
|
source.extension = safeGetString(src, PROP_SRC_TYPE, null)
|
||||||
|
source.textTracksAllowChuncklessPreparation = safeGetBool(src, PROP_SRC_TEXT_TRACKS_ALLOW_CHUNCKLESS_PREPARATION, true)
|
||||||
|
|
||||||
val propSrcHeadersArray = safeGetArray(src, PROP_SRC_HEADERS)
|
val propSrcHeadersArray = safeGetArray(src, PROP_SRC_HEADERS)
|
||||||
if (propSrcHeadersArray != null) {
|
if (propSrcHeadersArray != null) {
|
||||||
|
@ -1044,7 +1044,7 @@ public class ReactExoplayerView extends FrameLayout implements
|
|||||||
|
|
||||||
mediaSourceFactory = new HlsMediaSource.Factory(
|
mediaSourceFactory = new HlsMediaSource.Factory(
|
||||||
mediaDataSourceFactory
|
mediaDataSourceFactory
|
||||||
);
|
).setAllowChunklessPreparation(source.getTextTracksAllowChuncklessPreparation());
|
||||||
break;
|
break;
|
||||||
case CONTENT_TYPE_OTHER:
|
case CONTENT_TYPE_OTHER:
|
||||||
if ("asset".equals(uri.getScheme())) {
|
if ("asset".equals(uri.getScheme())) {
|
||||||
|
@ -753,7 +753,7 @@ source={{ uri: 'https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8'
|
|||||||
|
|
||||||
#### Overriding the metadata of a source
|
#### Overriding the metadata of a source
|
||||||
|
|
||||||
<PlatformsList types={['Android, iOS, tvOS']} />
|
<PlatformsList types={['Android', 'iOS', 'tvOS']} />
|
||||||
|
|
||||||
Provide an optional `title`, `subtitle`, `artist`, `imageUri` and/or `description` properties for the video.
|
Provide an optional `title`, `subtitle`, `artist`, `imageUri` and/or `description` properties for the video.
|
||||||
Useful when using notification controls on Android or iOS or to adapt the tvOS playback experience.
|
Useful when using notification controls on Android or iOS or to adapt the tvOS playback experience.
|
||||||
@ -773,6 +773,21 @@ source={{
|
|||||||
}}
|
}}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### `textTracksAllowChunklessPreparation`
|
||||||
|
<PlatformsList types={['Android']} />
|
||||||
|
|
||||||
|
AllowChunklessPreparation for hls media source.
|
||||||
|
see: [disabling-chunkless](https://developer.android.com/media/media3/exoplayer/hls?#disabling-chunkless) in android documentation.
|
||||||
|
|
||||||
|
Default value: true.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
source={{
|
||||||
|
uri: 'https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8',
|
||||||
|
textTracksAllowChunklessPreparation: false,
|
||||||
|
}}
|
||||||
|
```
|
||||||
|
|
||||||
### `subtitleStyle`
|
### `subtitleStyle`
|
||||||
|
|
||||||
| Property | Description | Platforms |
|
| Property | Description | Platforms |
|
||||||
|
@ -39,6 +39,7 @@ export type VideoSrc = Readonly<{
|
|||||||
cropStart?: Float;
|
cropStart?: Float;
|
||||||
cropEnd?: Float;
|
cropEnd?: Float;
|
||||||
metadata?: VideoMetadata;
|
metadata?: VideoMetadata;
|
||||||
|
textTracksAllowChunklessPreparation?: boolean; // android
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
type DRMType = WithDefault<string, 'widevine'>;
|
type DRMType = WithDefault<string, 'widevine'>;
|
||||||
|
@ -23,6 +23,7 @@ export type ReactVideoSourceProperties = {
|
|||||||
cropStart?: number;
|
cropStart?: number;
|
||||||
cropEnd?: number;
|
cropEnd?: number;
|
||||||
metadata?: VideoMetadata;
|
metadata?: VideoMetadata;
|
||||||
|
textTracksAllowChunklessPreparation?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ReactVideoSource = Readonly<
|
export type ReactVideoSource = Readonly<
|
||||||
|
Loading…
Reference in New Issue
Block a user