feat: support for video meta info

This commit is contained in:
Bnyro 2023-08-07 18:02:42 +02:00
parent fe100ad581
commit 81b8caa077
4 changed files with 33 additions and 1 deletions

View File

@ -0,0 +1,11 @@
package com.github.libretube.api.obj
import kotlinx.serialization.Serializable
@Serializable
data class MetaInfo(
val title: String,
val description: String,
val urls: List<String>,
val urlTexts: List<String>
)

View File

@ -21,6 +21,7 @@ data class Streams(
val license: String,
val visibility: String,
val tags: List<String>,
val metaInfo: List<MetaInfo>,
val hls: String? = null,
val dash: String? = null,
val lbryId: String? = null,

View File

@ -16,6 +16,7 @@ import android.os.PowerManager
import android.text.format.DateUtils
import android.text.method.LinkMovementMethod
import android.text.util.Linkify
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@ -861,6 +862,17 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
playerTitle.text = streams.title
playerDescription.text = streams.description
metaInfo.isVisible = streams.metaInfo.isNotEmpty()
// generate a meta info text with clickable links using html
val metaInfoText = streams.metaInfo.joinToString("\n\n") { info ->
val text = info.description.takeIf { it.isNotBlank() } ?: info.title
val links = info.urls.mapIndexed { index, url ->
"<a href=\"$url\">${info.urlTexts.getOrNull(index).orEmpty()}</a>"
}.joinToString(", ")
"$text $links"
}
metaInfo.text = metaInfoText.parseAsHtml()
playerChannelSubCount.text = context?.getString(
R.string.subscribers,
streams.uploaderSubscriberCount.formatShort()

View File

@ -107,6 +107,14 @@
android:orientation="vertical"
android:visibility="gone">
<TextView
android:id="@+id/meta_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:textSize="14sp"
android:visibility="gone" />
<TextView
android:id="@+id/player_description"
android:layout_width="match_parent"