-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(android): make buffering strategy dynamic (#3756)
* chore: rework bufferConfig to make it more generic and reduce ReactExoplayerView code size * feat: expose bufferingStrategy to app and change default behavior rename disableBuffering undocumented prop to bufferingStrategy and document it. before this change, default was 'dependingOnMemory'. It can trigger some unnecessary gc() call on android.
- Loading branch information
Showing
7 changed files
with
105 additions
and
31 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
android/src/main/java/com/brentvatne/common/api/BufferingStrategy.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.brentvatne.common.api | ||
|
||
import com.brentvatne.common.toolbox.DebugLog | ||
|
||
/** | ||
* Define how exoplayer with load data and parsing helper | ||
*/ | ||
|
||
class BufferingStrategy { | ||
|
||
/** | ||
* Define how exoplayer with load data | ||
*/ | ||
enum class BufferingStrategyEnum { | ||
/** | ||
* default exoplayer strategy | ||
*/ | ||
Default, | ||
|
||
/** | ||
* never load more than needed | ||
*/ | ||
DisableBuffering, | ||
|
||
/** | ||
* use default strategy but pause loading when available memory is low | ||
*/ | ||
DependingOnMemory | ||
} | ||
|
||
companion object { | ||
private const val TAG = "BufferingStrategy" | ||
|
||
/** | ||
* companion function to transform input string to enum | ||
*/ | ||
fun parse(src: String?): BufferingStrategyEnum { | ||
if (src == null) return BufferingStrategyEnum.Default | ||
return try { | ||
BufferingStrategyEnum.valueOf(src) | ||
} catch (e: Exception) { | ||
DebugLog.e(TAG, "cannot parse buffering strategy " + src) | ||
BufferingStrategyEnum.Default | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters