mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 16:00:31 +05:30
viewbind playerview
This commit is contained in:
parent
13ba954c6d
commit
afd71c7c54
@ -80,7 +80,6 @@ import com.google.android.exoplayer2.upstream.DefaultDataSource
|
||||
import com.google.android.exoplayer2.upstream.DefaultHttpDataSource
|
||||
import com.google.android.exoplayer2.util.RepeatModeUtil
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import com.google.android.material.card.MaterialCardView
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.squareup.picasso.Picasso
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
@ -233,7 +232,7 @@ class PlayerFragment : Fragment() {
|
||||
.remove(this)
|
||||
.commit()
|
||||
}
|
||||
view.findViewById<ImageButton>(R.id.close_imageButton).setOnClickListener {
|
||||
binding.player.binding.closeImageButton.setOnClickListener {
|
||||
isMiniPlayerVisible = false
|
||||
binding.playerMotionLayout.transitionToEnd()
|
||||
val mainActivity = activity as MainActivity
|
||||
@ -261,13 +260,12 @@ class PlayerFragment : Fragment() {
|
||||
if (binding.descLinLayout.isVisible) View.GONE else View.VISIBLE
|
||||
}
|
||||
|
||||
view.findViewById<MaterialCardView>(R.id.comments_toggle)
|
||||
.setOnClickListener {
|
||||
binding.commentsToggle.setOnClickListener {
|
||||
toggleComments()
|
||||
}
|
||||
|
||||
val fullScreenButton = view.findViewById<ImageButton>(R.id.fullscreen)
|
||||
val exoTitle = view.findViewById<TextView>(R.id.exo_title)
|
||||
val fullScreenButton = binding.player.binding.fullscreen
|
||||
val exoTitle = binding.player.binding.exoTitle
|
||||
|
||||
// FullScreen button trigger
|
||||
fullScreenButton.setOnClickListener {
|
||||
@ -303,7 +301,8 @@ class PlayerFragment : Fragment() {
|
||||
}
|
||||
|
||||
// switching between original aspect ratio (black bars) and zoomed to fill device screen
|
||||
view.findViewById<ImageButton>(R.id.aspect_ratio_button).setOnClickListener {
|
||||
val aspectRatioButton = binding.player.binding.aspectRatioButton
|
||||
aspectRatioButton.setOnClickListener {
|
||||
if (isZoomed) {
|
||||
exoPlayerView.resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FIT
|
||||
isZoomed = false
|
||||
@ -314,7 +313,7 @@ class PlayerFragment : Fragment() {
|
||||
}
|
||||
|
||||
// lock and unlock the player
|
||||
val lockPlayerButton = view.findViewById<ImageButton>(R.id.lock_player)
|
||||
val lockPlayerButton = binding.player.binding.lockPlayer
|
||||
lockPlayerButton.setOnClickListener {
|
||||
// change the locked/unlocked icon
|
||||
if (!isPlayerLocked) {
|
||||
@ -630,7 +629,7 @@ class PlayerFragment : Fragment() {
|
||||
binding.playerTitle.text = response.title
|
||||
binding.playerDescription.text = response.description
|
||||
|
||||
view.findViewById<TextView>(R.id.exo_title).text = response.title
|
||||
binding.player.binding.exoTitle.text = response.title
|
||||
|
||||
// Listener for play and pause icon change
|
||||
exoPlayer.addListener(object : Player.Listener {
|
||||
@ -802,8 +801,8 @@ class PlayerFragment : Fragment() {
|
||||
PreferenceHelper.getString(requireContext(), "player_video_format", "WEBM")
|
||||
val defres = PreferenceHelper.getString(requireContext(), "default_res", "")!!
|
||||
|
||||
val qualityText = view.findViewById<TextView>(R.id.quality_text)
|
||||
val qualitySelect = view.findViewById<LinearLayout>(R.id.quality_linLayout)
|
||||
val qualityText = binding.player.binding.qualityText
|
||||
val qualitySelect = binding.player.binding.qualitySelect
|
||||
|
||||
var videosNameArray: Array<CharSequence> = arrayOf()
|
||||
var videosUrlArray: Array<Uri> = arrayOf()
|
||||
@ -987,12 +986,12 @@ class PlayerFragment : Fragment() {
|
||||
|
||||
private fun lockPlayer(isLocked: Boolean) {
|
||||
val visibility = if (isLocked) View.VISIBLE else View.INVISIBLE
|
||||
exoPlayerView.findViewById<LinearLayout>(R.id.exo_top_bar_right).visibility = visibility
|
||||
exoPlayerView.findViewById<ImageButton>(R.id.exo_play_pause).visibility = visibility
|
||||
exoPlayerView.findViewById<Button>(R.id.exo_ffwd_with_amount).visibility = visibility
|
||||
exoPlayerView.findViewById<Button>(R.id.exo_rew_with_amount).visibility = visibility
|
||||
exoPlayerView.findViewById<FrameLayout>(R.id.exo_bottom_bar).visibility = visibility
|
||||
exoPlayerView.findViewById<TextView>(R.id.exo_title).visibility =
|
||||
binding.player.binding.exoTopBarRight.visibility = visibility
|
||||
binding.player.binding.exoPlayPause.visibility = visibility
|
||||
binding.player.binding.exoFfwdWithAmount.visibility = visibility
|
||||
binding.player.binding.exoRewWithAmount.visibility = visibility
|
||||
binding.player.binding.exoBottomBar.visibility = visibility
|
||||
binding.player.binding.exoTitle.visibility =
|
||||
if (isLocked && isFullScreen) View.VISIBLE else View.INVISIBLE
|
||||
}
|
||||
|
||||
@ -1154,7 +1153,7 @@ class PlayerFragment : Fragment() {
|
||||
enableTransition(R.id.yt_transition, false)
|
||||
}
|
||||
binding.mainContainer.isClickable = true
|
||||
view?.findViewById<LinearLayout>(R.id.exo_top_bar)?.visibility = View.GONE
|
||||
binding.player.binding.exoTopBar.visibility = View.GONE
|
||||
val mainActivity = activity as MainActivity
|
||||
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
|
||||
isFullScreen = false
|
||||
@ -1166,7 +1165,7 @@ class PlayerFragment : Fragment() {
|
||||
exoPlayerView.showController()
|
||||
exoPlayerView.useController = true
|
||||
binding.mainContainer.isClickable = false
|
||||
view?.findViewById<LinearLayout>(R.id.exo_top_bar)?.visibility = View.VISIBLE
|
||||
binding.player.binding.exoTopBar.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,12 +4,14 @@ import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import com.github.libretube.databinding.ExoStyledPlayerControlViewBinding
|
||||
import com.google.android.exoplayer2.ui.StyledPlayerView
|
||||
|
||||
internal class CustomExoPlayerView(
|
||||
context: Context,
|
||||
attributeSet: AttributeSet? = null
|
||||
) : StyledPlayerView(context, attributeSet) {
|
||||
val binding: ExoStyledPlayerControlViewBinding = ExoStyledPlayerControlViewBinding.bind(this)
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||
|
Loading…
x
Reference in New Issue
Block a user