mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
f5482a8fb2
3 changed files with 25 additions and 8 deletions
|
@ -73,7 +73,7 @@ class CustomDecoder : SubtitleDecoder {
|
||||||
private var realDecoder: SubtitleDecoder? = null
|
private var realDecoder: SubtitleDecoder? = null
|
||||||
|
|
||||||
override fun getName(): String {
|
override fun getName(): String {
|
||||||
return realDecoder?.name ?: this::class.java.name
|
return realDecoder?.name ?: this::javaClass.name
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun dequeueInputBuffer(): SubtitleInputBuffer {
|
override fun dequeueInputBuffer(): SubtitleInputBuffer {
|
||||||
|
@ -127,6 +127,11 @@ class CustomDecoder : SubtitleDecoder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun SubtitleInputBuffer.setSubtitleText(text: String) {
|
||||||
|
// println("Set subtitle text -----\n$text\n-----")
|
||||||
|
this.data = ByteBuffer.wrap(text.toByteArray(charset(UTF_8)))
|
||||||
|
}
|
||||||
|
|
||||||
override fun queueInputBuffer(inputBuffer: SubtitleInputBuffer) {
|
override fun queueInputBuffer(inputBuffer: SubtitleInputBuffer) {
|
||||||
Log.i(TAG, "queueInputBuffer")
|
Log.i(TAG, "queueInputBuffer")
|
||||||
try {
|
try {
|
||||||
|
@ -152,7 +157,7 @@ class CustomDecoder : SubtitleDecoder {
|
||||||
)
|
)
|
||||||
realDecoder?.let { decoder ->
|
realDecoder?.let { decoder ->
|
||||||
decoder.dequeueInputBuffer()?.let { buff ->
|
decoder.dequeueInputBuffer()?.let { buff ->
|
||||||
if (decoder::class.java != SsaDecoder::class.java) {
|
if (decoder !is SsaDecoder) {
|
||||||
if (regexSubtitlesToRemoveCaptions)
|
if (regexSubtitlesToRemoveCaptions)
|
||||||
captionRegex.forEach { rgx ->
|
captionRegex.forEach { rgx ->
|
||||||
str = str.replace(rgx, "\n")
|
str = str.replace(rgx, "\n")
|
||||||
|
@ -162,8 +167,7 @@ class CustomDecoder : SubtitleDecoder {
|
||||||
str = str.replace(rgx, "\n")
|
str = str.replace(rgx, "\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buff.data = ByteBuffer.wrap(str.toByteArray(charset(UTF_8)))
|
buff.setSubtitleText(str)
|
||||||
|
|
||||||
decoder.queueInputBuffer(buff)
|
decoder.queueInputBuffer(buff)
|
||||||
Log.i(
|
Log.i(
|
||||||
TAG,
|
TAG,
|
||||||
|
@ -180,7 +184,7 @@ class CustomDecoder : SubtitleDecoder {
|
||||||
|
|
||||||
if (!inputString.isNullOrBlank()) {
|
if (!inputString.isNullOrBlank()) {
|
||||||
var str: String = inputString
|
var str: String = inputString
|
||||||
if (realDecoder!!::class.java != SsaDecoder::class.java) {
|
if (realDecoder !is SsaDecoder) {
|
||||||
if (regexSubtitlesToRemoveCaptions)
|
if (regexSubtitlesToRemoveCaptions)
|
||||||
captionRegex.forEach { rgx ->
|
captionRegex.forEach { rgx ->
|
||||||
str = str.replace(rgx, "\n")
|
str = str.replace(rgx, "\n")
|
||||||
|
@ -190,7 +194,7 @@ class CustomDecoder : SubtitleDecoder {
|
||||||
str = str.replace(rgx, "\n")
|
str = str.replace(rgx, "\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inputBuffer.data = ByteBuffer.wrap(str.toByteArray(charset(UTF_8)))
|
inputBuffer.setSubtitleText(str)
|
||||||
}
|
}
|
||||||
|
|
||||||
realDecoder?.queueInputBuffer(inputBuffer)
|
realDecoder?.queueInputBuffer(inputBuffer)
|
||||||
|
|
|
@ -22,6 +22,8 @@ import androidx.annotation.IntDef
|
||||||
import com.google.android.exoplayer2.*
|
import com.google.android.exoplayer2.*
|
||||||
import com.google.android.exoplayer2.source.SampleStream.ReadDataResult
|
import com.google.android.exoplayer2.source.SampleStream.ReadDataResult
|
||||||
import com.google.android.exoplayer2.text.*
|
import com.google.android.exoplayer2.text.*
|
||||||
|
import com.google.android.exoplayer2.text.Cue.DIMEN_UNSET
|
||||||
|
import com.google.android.exoplayer2.text.Cue.LINE_TYPE_NUMBER
|
||||||
import com.google.android.exoplayer2.util.Assertions
|
import com.google.android.exoplayer2.util.Assertions
|
||||||
import com.google.android.exoplayer2.util.Log
|
import com.google.android.exoplayer2.util.Log
|
||||||
import com.google.android.exoplayer2.util.MimeTypes
|
import com.google.android.exoplayer2.util.MimeTypes
|
||||||
|
@ -308,7 +310,18 @@ open class NonFinalTextRenderer @JvmOverloads constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun invokeUpdateOutputInternal(cues: List<Cue>) {
|
private fun invokeUpdateOutputInternal(cues: List<Cue>) {
|
||||||
output.onCues(cues.map { cue -> cue.buildUpon().setSize(Cue.DIMEN_UNSET).build() }) // this fixes https://github.com/LagradOst/CloudStream-3/issues/717
|
output.onCues(cues.map { cue ->
|
||||||
|
val builder = cue.buildUpon()
|
||||||
|
|
||||||
|
// See https://github.com/google/ExoPlayer/issues/7934
|
||||||
|
// SubripDecoder texts tend to be DIMEN_UNSET which pushes up the
|
||||||
|
// subs unlike WEBVTT which creates an inconsistency
|
||||||
|
if (cue.line == DIMEN_UNSET)
|
||||||
|
builder.setLine(-1f, LINE_TYPE_NUMBER)
|
||||||
|
|
||||||
|
// this fixes https://github.com/LagradOst/CloudStream-3/issues/717
|
||||||
|
builder.setSize(DIMEN_UNSET).build()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
<ImageView
|
<ImageView
|
||||||
android:nextFocusDown="@id/result_bookmark_button"
|
android:nextFocusDown="@id/result_bookmark_button"
|
||||||
|
|
Loading…
Reference in a new issue