mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 06:40:30 +05:30
seekbar preview
This commit is contained in:
parent
94191e24cc
commit
53f9d41d31
@ -508,7 +508,7 @@ class PlayerFragment : Fragment() {
|
|||||||
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
// set media sources for the player
|
// set media sources for the player
|
||||||
setResolutionAndSubtitles(view, response)
|
setResolutionAndSubtitles(response)
|
||||||
prepareExoPlayerView()
|
prepareExoPlayerView()
|
||||||
initializePlayerView(view, response)
|
initializePlayerView(view, response)
|
||||||
seekToWatchPosition()
|
seekToWatchPosition()
|
||||||
@ -981,10 +981,15 @@ class PlayerFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onScrubMove(timeBar: TimeBar, position: Long) {
|
override fun onScrubMove(timeBar: TimeBar, position: Long) {
|
||||||
exoPlayer.seekTo(position)
|
val minTimeDiff = 10 * 1000 // 10s
|
||||||
|
// get the difference between the new and the old position
|
||||||
|
val diff = abs(exoPlayer.currentPosition - position)
|
||||||
|
// seek only when the difference is greater than 10 seconds
|
||||||
|
if (diff >= minTimeDiff) exoPlayer.seekTo(position)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onScrubStop(timeBar: TimeBar, position: Long, canceled: Boolean) {
|
override fun onScrubStop(timeBar: TimeBar, position: Long, canceled: Boolean) {
|
||||||
|
exoPlayer.seekTo(position)
|
||||||
exoPlayer.play()
|
exoPlayer.play()
|
||||||
Handler(Looper.getMainLooper()).postDelayed({
|
Handler(Looper.getMainLooper()).postDelayed({
|
||||||
exoPlayerView.hideController()
|
exoPlayerView.hideController()
|
||||||
@ -1033,7 +1038,7 @@ class PlayerFragment : Fragment() {
|
|||||||
// call the function again in 100ms
|
// call the function again in 100ms
|
||||||
exoPlayerView.postDelayed(this::setCurrentChapterName, 100)
|
exoPlayerView.postDelayed(this::setCurrentChapterName, 100)
|
||||||
|
|
||||||
var chapterName = getCurrentChapterName()
|
val chapterName = getCurrentChapterName()
|
||||||
|
|
||||||
// change the chapter name textView text to the chapterName
|
// change the chapter name textView text to the chapterName
|
||||||
if (chapterName != null && chapterName != playerBinding.chapterName.text) {
|
if (chapterName != null && chapterName != playerBinding.chapterName.text) {
|
||||||
@ -1078,7 +1083,7 @@ class PlayerFragment : Fragment() {
|
|||||||
exoPlayer.setMediaSource(mergeSource)
|
exoPlayer.setMediaSource(mergeSource)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setResolutionAndSubtitles(view: View, response: Streams) {
|
private fun setResolutionAndSubtitles(response: Streams) {
|
||||||
val videoFormatPreference =
|
val videoFormatPreference =
|
||||||
PreferenceHelper.getString(requireContext(), "player_video_format", "WEBM")
|
PreferenceHelper.getString(requireContext(), "player_video_format", "WEBM")
|
||||||
val defres = PreferenceHelper.getString(requireContext(), "default_res", "")!!
|
val defres = PreferenceHelper.getString(requireContext(), "default_res", "")!!
|
||||||
@ -1312,7 +1317,7 @@ class PlayerFragment : Fragment() {
|
|||||||
private fun subscribe(channel_id: String) {
|
private fun subscribe(channel_id: String) {
|
||||||
fun run() {
|
fun run() {
|
||||||
lifecycleScope.launchWhenCreated {
|
lifecycleScope.launchWhenCreated {
|
||||||
val response = try {
|
try {
|
||||||
val token = PreferenceHelper.getToken(requireContext())
|
val token = PreferenceHelper.getToken(requireContext())
|
||||||
RetrofitInstance.authApi.subscribe(
|
RetrofitInstance.authApi.subscribe(
|
||||||
token,
|
token,
|
||||||
@ -1335,7 +1340,7 @@ class PlayerFragment : Fragment() {
|
|||||||
private fun unsubscribe(channel_id: String) {
|
private fun unsubscribe(channel_id: String) {
|
||||||
fun run() {
|
fun run() {
|
||||||
lifecycleScope.launchWhenCreated {
|
lifecycleScope.launchWhenCreated {
|
||||||
val response = try {
|
try {
|
||||||
val token = PreferenceHelper.getToken(requireContext())
|
val token = PreferenceHelper.getToken(requireContext())
|
||||||
RetrofitInstance.authApi.unsubscribe(
|
RetrofitInstance.authApi.unsubscribe(
|
||||||
token,
|
token,
|
||||||
|
@ -5,7 +5,7 @@ import android.os.Looper
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
|
|
||||||
class DoubleClickListener(
|
class DoubleClickListener(
|
||||||
private val doubleClickTimeLimitMills: Long = 300,
|
private val doubleClickTimeLimitMills: Long = 200,
|
||||||
private val callback: Callback
|
private val callback: Callback
|
||||||
) : View.OnClickListener {
|
) : View.OnClickListener {
|
||||||
private var lastClicked: Long = -1L
|
private var lastClicked: Long = -1L
|
||||||
|
Loading…
Reference in New Issue
Block a user