mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 06:40:30 +05:30
feat: support for video meta info
This commit is contained in:
parent
fe100ad581
commit
81b8caa077
11
app/src/main/java/com/github/libretube/api/obj/MetaInfo.kt
Normal file
11
app/src/main/java/com/github/libretube/api/obj/MetaInfo.kt
Normal 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>
|
||||
)
|
@ -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,
|
||||
|
@ -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()
|
||||
|
@ -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"
|
||||
@ -126,7 +134,7 @@
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/tags_recycler"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user