mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20:30 +05:30
commit
8d22c56c2f
@ -907,7 +907,7 @@ class PlayerFragment : BaseFragment() {
|
||||
if (!this::autoPlayHelper.isInitialized) autoPlayHelper = AutoPlayHelper(playlistId)
|
||||
// search for the next videoId in the playlist
|
||||
lifecycleScope.launchWhenCreated {
|
||||
nextStreamId = autoPlayHelper.getNextVideoId(videoId!!, streams.relatedStreams!!)
|
||||
nextStreamId = autoPlayHelper.getNextVideoId(videoId!!, streams.relatedStreams)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1294,42 +1294,44 @@ class PlayerFragment : BaseFragment() {
|
||||
}
|
||||
|
||||
private fun initializeChapters() {
|
||||
if (chapters.isNotEmpty()) {
|
||||
// enable chapters in the video description
|
||||
binding.chaptersRecView.layoutManager =
|
||||
LinearLayoutManager(
|
||||
context,
|
||||
LinearLayoutManager.HORIZONTAL,
|
||||
false
|
||||
)
|
||||
binding.chaptersRecView.adapter = ChaptersAdapter(chapters, exoPlayer)
|
||||
binding.chaptersRecView.visibility = View.VISIBLE
|
||||
if (chapters.isEmpty()) return
|
||||
// enable chapters in the video description
|
||||
binding.chaptersRecView.layoutManager =
|
||||
LinearLayoutManager(
|
||||
context,
|
||||
LinearLayoutManager.HORIZONTAL,
|
||||
false
|
||||
)
|
||||
binding.chaptersRecView.adapter = ChaptersAdapter(chapters, exoPlayer)
|
||||
binding.chaptersRecView.visibility = View.VISIBLE
|
||||
|
||||
// enable the chapters dialog in the player
|
||||
val titles = mutableListOf<String>()
|
||||
chapters.forEach {
|
||||
titles += it.title!!
|
||||
}
|
||||
playerBinding.chapterLL.visibility = View.VISIBLE
|
||||
playerBinding.chapterLL.setOnClickListener {
|
||||
if (viewModel.isFullscreen.value!!) {
|
||||
MaterialAlertDialogBuilder(requireContext())
|
||||
.setTitle(R.string.chapters)
|
||||
.setItems(titles.toTypedArray()) { _, index ->
|
||||
val position = chapters[index].start!! * 1000
|
||||
exoPlayer.seekTo(position)
|
||||
}
|
||||
.show()
|
||||
} else {
|
||||
toggleDescription()
|
||||
}
|
||||
}
|
||||
setCurrentChapterName()
|
||||
// enable the chapters dialog in the player
|
||||
val titles = mutableListOf<String>()
|
||||
chapters.forEach {
|
||||
titles += it.title!!
|
||||
}
|
||||
playerBinding.chapterLL.visibility = View.VISIBLE
|
||||
playerBinding.chapterLL.setOnClickListener {
|
||||
if (viewModel.isFullscreen.value!!) {
|
||||
MaterialAlertDialogBuilder(requireContext())
|
||||
.setTitle(R.string.chapters)
|
||||
.setItems(titles.toTypedArray()) { _, index ->
|
||||
val position = chapters[index].start!! * 1000
|
||||
exoPlayer.seekTo(position)
|
||||
}
|
||||
.show()
|
||||
} else {
|
||||
toggleDescription()
|
||||
}
|
||||
}
|
||||
setCurrentChapterName()
|
||||
}
|
||||
|
||||
// set the name of the video chapter in the exoPlayerView
|
||||
private fun setCurrentChapterName() {
|
||||
// return if chapters are ampty to avoid crashes
|
||||
if (chapters.isEmpty()) return
|
||||
|
||||
// call the function again in 100ms
|
||||
exoPlayerView.postDelayed(this::setCurrentChapterName, 100)
|
||||
|
||||
|
@ -13,9 +13,12 @@ class AutoPlayHelper(
|
||||
private val playlistStreamIds = mutableListOf<String>()
|
||||
private var playlistNextPage: String? = null
|
||||
|
||||
/**
|
||||
* get the id of the next video to be played
|
||||
*/
|
||||
suspend fun getNextVideoId(
|
||||
currentVideoId: String,
|
||||
relatedStreams: List<StreamItem>
|
||||
relatedStreams: List<StreamItem>?
|
||||
): String? {
|
||||
return if (Globals.playingQueue.last() != currentVideoId) {
|
||||
val currentVideoIndex = Globals.playingQueue.indexOf(currentVideoId)
|
||||
@ -28,8 +31,15 @@ class AutoPlayHelper(
|
||||
)
|
||||
}
|
||||
|
||||
private fun getNextTrendingVideoId(videoId: String, relatedStreams: List<StreamItem>): String? {
|
||||
/**
|
||||
* get the id of the next related video
|
||||
*/
|
||||
private fun getNextTrendingVideoId(
|
||||
videoId: String,
|
||||
relatedStreams: List<StreamItem>?
|
||||
): String? {
|
||||
// don't play a video if it got played before already
|
||||
if (relatedStreams == null || relatedStreams.isEmpty()) return null
|
||||
var index = 0
|
||||
var nextStreamId: String? = null
|
||||
while (nextStreamId == null ||
|
||||
@ -47,6 +57,9 @@ class AutoPlayHelper(
|
||||
return nextStreamId
|
||||
}
|
||||
|
||||
/**
|
||||
* get the videoId of the next video in a playlist
|
||||
*/
|
||||
private suspend fun getNextPlaylistVideoId(currentVideoId: String): String? {
|
||||
// if the playlists contain the video, then save the next video as next stream
|
||||
if (playlistStreamIds.contains(currentVideoId)) {
|
||||
@ -76,6 +89,9 @@ class AutoPlayHelper(
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* get the videoId of the next video in the playing queue
|
||||
*/
|
||||
fun getNextPlayingQueueVideoId(
|
||||
currentVideoId: String
|
||||
): String? {
|
||||
|
@ -165,7 +165,7 @@ object NotificationHelper {
|
||||
|
||||
val builder = NotificationCompat.Builder(context, PUSH_CHANNEL_ID)
|
||||
.setContentTitle(title)
|
||||
.setSmallIcon(R.drawable.ic_bell)
|
||||
.setSmallIcon(R.drawable.ic_notification)
|
||||
.setContentText(description)
|
||||
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
||||
// Set the intent that will fire when the user taps the notification
|
||||
|
@ -1,10 +0,0 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="18dp"
|
||||
android:height="20dp"
|
||||
android:viewportWidth="18"
|
||||
android:viewportHeight="20">
|
||||
<path
|
||||
android:fillColor="#E6E1E5"
|
||||
android:fillType="evenOdd"
|
||||
android:pathData="M8.625,0H9.375C9.5821,0 9.75,0.1679 9.75,0.375C9.75,0.5821 9.9179,0.75 10.125,0.75C10.3321,0.75 10.5,0.9179 10.5,1.125V1.875C10.5,2.4963 11.0088,3.0566 11.5685,3.3265C12.4353,3.7446 13.5132,4.5489 14.0889,5.6503C14.2067,5.8758 14.25,6.1307 14.25,6.3852V12.0512C14.25,12.9156 14.8488,13.6151 15.5614,14.1044C15.8681,14.315 16.102,14.5525 16.3642,14.8462C16.4522,14.9448 16.5,15.0728 16.5,15.2049C16.5,15.506 16.256,15.75 15.955,15.75H2.051C1.7467,15.75 1.5,15.5033 1.5,15.199C1.5,15.0704 1.5445,14.9452 1.6287,14.848C1.8916,14.5448 2.1396,14.3062 2.4619,14.0946C3.1737,13.6273 3.75,12.9293 3.75,12.0778V6.3852C3.75,6.1307 3.7933,5.8758 3.9111,5.6503C4.4868,4.5489 5.5648,3.7446 6.4316,3.3265C6.9912,3.0566 7.5,2.4963 7.5,1.875V1.125C7.5,0.9179 7.6679,0.75 7.875,0.75C8.0821,0.75 8.25,0.5821 8.25,0.375C8.25,0.1679 8.4179,0 8.625,0ZM9,19.4998C7.7574,19.4998 6.7501,18.4925 6.75,17.2499H11.25C11.2499,18.4925 10.2426,19.4998 9,19.4998ZM0.0558,7.5132C-0.1246,6.2857 0.1356,5.034 0.7902,3.9801C1.4447,2.9262 2.4513,2.1382 3.6315,1.7557L3.9552,2.7546C3.0111,3.0605 2.2058,3.691 1.6821,4.5341C1.1585,5.3772 0.9503,6.3786 1.0946,7.3605L0.0558,7.5132ZM17.1808,3.934C16.5153,2.8869 15.5006,2.1094 14.3165,1.7392L14.0032,2.7414C14.9504,3.0375 15.7623,3.6596 16.2946,4.4972C16.827,5.3348 17.0455,6.334 16.9115,7.3174L17.9519,7.4592C18.1194,6.2299 17.8463,4.981 17.1808,3.934Z" />
|
||||
</vector>
|
@ -1,10 +0,0 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="14dp"
|
||||
android:height="16dp"
|
||||
android:viewportWidth="18"
|
||||
android:viewportHeight="20">
|
||||
<path
|
||||
android:fillColor="#E6E1E5"
|
||||
android:fillType="evenOdd"
|
||||
android:pathData="M8.625,0H9.375C9.5821,0 9.75,0.1679 9.75,0.375C9.75,0.5821 9.9179,0.75 10.125,0.75C10.3321,0.75 10.5,0.9179 10.5,1.125V1.875C10.5,2.4963 11.0088,3.0566 11.5685,3.3265C12.4353,3.7446 13.5132,4.5489 14.0889,5.6503C14.2067,5.8758 14.25,6.1307 14.25,6.3852V12.0512C14.25,12.9156 14.8488,13.6151 15.5614,14.1044C15.8681,14.315 16.102,14.5525 16.3642,14.8462C16.4522,14.9448 16.5,15.0728 16.5,15.2049C16.5,15.506 16.256,15.75 15.955,15.75H2.051C1.7467,15.75 1.5,15.5033 1.5,15.199C1.5,15.0704 1.5445,14.9452 1.6287,14.848C1.8916,14.5448 2.1396,14.3062 2.4619,14.0946C3.1737,13.6273 3.75,12.9293 3.75,12.0778V6.3852C3.75,6.1307 3.7933,5.8758 3.9111,5.6503C4.4868,4.5489 5.5648,3.7446 6.4316,3.3265C6.9912,3.0566 7.5,2.4963 7.5,1.875V1.125C7.5,0.9179 7.6679,0.75 7.875,0.75C8.0821,0.75 8.25,0.5821 8.25,0.375C8.25,0.1679 8.4179,0 8.625,0ZM9,19.4998C7.7574,19.4998 6.7501,18.4925 6.75,17.2499H11.25C11.2499,18.4925 10.2426,19.4998 9,19.4998ZM0.0558,7.5132C-0.1246,6.2857 0.1356,5.034 0.7902,3.9801C1.4447,2.9262 2.4513,2.1382 3.6315,1.7557L3.9552,2.7546C3.0111,3.0605 2.2058,3.691 1.6821,4.5341C1.1585,5.3772 0.9503,6.3786 1.0946,7.3605L0.0558,7.5132ZM17.1808,3.934C16.5153,2.8869 15.5006,2.1094 14.3165,1.7392L14.0032,2.7414C14.9504,3.0375 15.7623,3.6596 16.2946,4.4972C16.827,5.3348 17.0455,6.334 16.9115,7.3174L17.9519,7.4592C18.1194,6.2299 17.8463,4.981 17.1808,3.934Z" />
|
||||
</vector>
|
@ -1,14 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:width="22dp"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="?attr/colorControlNormal"
|
||||
android:viewportWidth="18"
|
||||
android:viewportHeight="20"
|
||||
tools:ignore="VectorRaster">
|
||||
android:viewportWidth="48"
|
||||
android:viewportHeight="48">
|
||||
<path
|
||||
android:fillColor="#E6E1E5"
|
||||
android:fillType="evenOdd"
|
||||
android:pathData="M8.625,0H9.375C9.5821,0 9.75,0.1679 9.75,0.375C9.75,0.5821 9.9179,0.75 10.125,0.75C10.3321,0.75 10.5,0.9179 10.5,1.125V1.875C10.5,2.4963 11.0088,3.0566 11.5685,3.3265C12.4353,3.7446 13.5132,4.5489 14.0889,5.6503C14.2067,5.8758 14.25,6.1307 14.25,6.3852V12.0512C14.25,12.9156 14.8488,13.6151 15.5614,14.1044C15.8681,14.315 16.102,14.5525 16.3642,14.8462C16.4522,14.9448 16.5,15.0728 16.5,15.2049C16.5,15.506 16.256,15.75 15.955,15.75H2.051C1.7467,15.75 1.5,15.5033 1.5,15.199C1.5,15.0704 1.5445,14.9452 1.6287,14.848C1.8916,14.5448 2.1396,14.3062 2.4619,14.0946C3.1737,13.6273 3.75,12.9293 3.75,12.0778V6.3852C3.75,6.1307 3.7933,5.8758 3.9111,5.6503C4.4868,4.5489 5.5648,3.7446 6.4316,3.3265C6.9912,3.0566 7.5,2.4963 7.5,1.875V1.125C7.5,0.9179 7.6679,0.75 7.875,0.75C8.0821,0.75 8.25,0.5821 8.25,0.375C8.25,0.1679 8.4179,0 8.625,0ZM9,19.4998C7.7574,19.4998 6.7501,18.4925 6.75,17.2499H11.25C11.2499,18.4925 10.2426,19.4998 9,19.4998ZM0.0558,7.5132C-0.1246,6.2857 0.1356,5.034 0.7902,3.9801C1.4447,2.9262 2.4513,2.1382 3.6315,1.7557L3.9552,2.7546C3.0111,3.0605 2.2058,3.691 1.6821,4.5341C1.1585,5.3772 0.9503,6.3786 1.0946,7.3605L0.0558,7.5132ZM17.1808,3.934C16.5153,2.8869 15.5006,2.1094 14.3165,1.7392L14.0032,2.7414C14.9504,3.0375 15.7623,3.6596 16.2946,4.4972C16.827,5.3348 17.0455,6.334 16.9115,7.3174L17.9519,7.4592C18.1194,6.2299 17.8463,4.981 17.1808,3.934Z"
|
||||
tools:ignore="VectorPath" />
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M6.2,19.65q0,-4.05 1.7,-7.675T12.75,5.8l2.05,2.25q-2.65,2.15 -4.125,5.175T9.2,19.65ZM38.85,19.65q0,-3.4 -1.4,-6.425T33.4,8.05l2.05,-2.25q3.1,2.6 4.75,6.2t1.65,7.65ZM8,38v-3h4.2L12.2,19.7q0,-4.1 2.475,-7.425T21.2,8.1L21.2,6.65q0,-1.15 0.825,-1.9T24,4q1.15,0 1.975,0.75 0.825,0.75 0.825,1.9L26.8,8.1q4.05,0.85 6.55,4.175 2.5,3.325 2.5,7.425L35.85,35L40,35v3ZM24,44q-1.6,0 -2.8,-1.175Q20,41.65 20,40h8q0,1.65 -1.175,2.825Q25.65,44 24,44Z" />
|
||||
</vector>
|
||||
|
@ -78,7 +78,6 @@
|
||||
style="@style/Widget.Material3.Button.ElevatedButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawableStart="@drawable/ic_bell_small"
|
||||
android:drawableTint="?android:attr/textColorPrimary"
|
||||
android:stateListAnimator="@null"
|
||||
android:text="@string/subscribe"
|
||||
|
@ -274,8 +274,6 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:drawableStart="@drawable/ic_bell"
|
||||
android:drawableTint="?android:attr/textColorPrimary"
|
||||
android:text="@string/subscribe"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="12sp"
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<menu xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
@ -8,7 +9,8 @@
|
||||
android:icon="@drawable/ic_search"
|
||||
android:title="@string/search_hint"
|
||||
app:actionViewClass="androidx.appcompat.widget.SearchView"
|
||||
app:showAsAction="ifRoom|collapseActionView" />
|
||||
app:showAsAction="always|collapseActionView"
|
||||
tools:ignore="AlwaysShowAction" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
|
Loading…
Reference in New Issue
Block a user