Merge pull request #4096 from Isira-Seneviratne/DisplayHelper

Improve DisplayHelper
This commit is contained in:
Isira Seneviratne 2023-06-25 12:09:24 +05:30 committed by GitHub
commit e59b490ad9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 12 deletions

View File

@ -11,12 +11,8 @@ object DisplayHelper {
* Returns false on and below SDK 24
*/
fun supportsHdr(context: Context): Boolean {
val displayManager = context.getSystemService(Context.DISPLAY_SERVICE) as DisplayManager
val display = displayManager.getDisplay(Display.DEFAULT_DISPLAY)
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
display.hdrCapabilities.supportedHdrTypes.isNotEmpty()
} else {
false
}
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N &&
context.getSystemService(DisplayManager::class.java).getDisplay(Display.DEFAULT_DISPLAY)
.hdrCapabilities.supportedHdrTypes.isNotEmpty()
}
}

View File

@ -59,11 +59,8 @@ object PlayerHelper {
* Create a base64 encoded DASH stream manifest
*/
fun createDashSource(streams: Streams, context: Context, audioOnly: Boolean = false): Uri {
val manifest = DashHelper.createManifest(
streams,
DisplayHelper.supportsHdr(context),
audioOnly
)
val supportsHdr = DisplayHelper.supportsHdr(context)
val manifest = DashHelper.createManifest(streams, supportsHdr, audioOnly)
// encode to base64
val encoded = Base64.encodeToString(manifest.toByteArray(), Base64.DEFAULT)