Skip to content

Commit

Permalink
feat: add sync supported text renderer (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
anilbeesetti authored Sep 3, 2023
1 parent 0ba5aa6 commit f24d77e
Show file tree
Hide file tree
Showing 3 changed files with 479 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,26 @@ package io.github.anilbeesetti.nextlib.ffcodecs

import android.content.Context
import android.os.Handler
import android.os.Looper
import androidx.media3.common.util.Log
import androidx.media3.exoplayer.DefaultRenderersFactory
import androidx.media3.exoplayer.Renderer
import androidx.media3.exoplayer.audio.AudioRendererEventListener
import androidx.media3.exoplayer.audio.AudioSink
import androidx.media3.exoplayer.mediacodec.MediaCodecSelector
import androidx.media3.exoplayer.text.TextOutput
import androidx.media3.exoplayer.video.VideoRendererEventListener
import io.github.anilbeesetti.nextlib.text.NextTextRenderer

class NextRenderersFactory(context: Context) : DefaultRenderersFactory(context) {

private var subtitleSyncOffsetUs = 0L

fun setSubtitleSyncOffsetUs(offsetUs: Long): NextRenderersFactory {
subtitleSyncOffsetUs = offsetUs
return this
}

override fun buildAudioRenderers(
context: Context,
extensionRendererMode: Int,
Expand Down Expand Up @@ -87,6 +98,17 @@ class NextRenderersFactory(context: Context) : DefaultRenderersFactory(context)
}
}

override fun buildTextRenderers(
context: Context,
output: TextOutput,
outputLooper: Looper,
extensionRendererMode: Int,
out: java.util.ArrayList<Renderer>
) {
val renderer = NextTextRenderer(subtitleSyncOffsetUs, output, outputLooper)
out.add(renderer)
}

companion object {
const val TAG = "NextRenderersFactory"
}
Expand Down
Loading

0 comments on commit f24d77e

Please sign in to comment.