diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index 6f44777cd..7427b0822 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -1,6 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.idea/misc.xml b/.idea/misc.xml index 880291fb8..9d11f06e0 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -17,6 +17,7 @@ + diff --git a/app/src/main/java/xyz/btcland/libretube/PlayerFragment.kt b/app/src/main/java/xyz/btcland/libretube/PlayerFragment.kt index 648dca3a8..c80115ec0 100644 --- a/app/src/main/java/xyz/btcland/libretube/PlayerFragment.kt +++ b/app/src/main/java/xyz/btcland/libretube/PlayerFragment.kt @@ -52,6 +52,8 @@ import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.text.PrecomputedTextCompat import androidx.recyclerview.widget.LinearLayoutManager +import com.google.android.exoplayer2.Player +import com.google.android.exoplayer2.Player.STATE_IDLE import com.google.android.exoplayer2.source.DefaultMediaSourceFactory import com.google.android.exoplayer2.util.RepeatModeUtil @@ -81,7 +83,7 @@ class PlayerFragment : Fragment() { private var whichQuality = 0 private lateinit var exoPlayerView: StyledPlayerView - private lateinit var motionLayout: SingleViewTouchableMotionLayout + private lateinit var motionLayout: MotionLayout private lateinit var exoPlayer: ExoPlayer private lateinit var mediaSource: MediaSource @@ -104,7 +106,7 @@ class PlayerFragment : Fragment() { super.onViewCreated(view, savedInstanceState) val mainActivity = activity as MainActivity mainActivity.findViewById(R.id.container).visibility=View.VISIBLE - val playerMotionLayout = view.findViewById(R.id.playerMotionLayout) + val playerMotionLayout = view.findViewById(R.id.playerMotionLayout) motionLayout = playerMotionLayout exoPlayerView = view.findViewById(R.id.player) view.findViewById(R.id.textTest).text = videoId @@ -242,7 +244,6 @@ class PlayerFragment : Fragment() { } } - private fun fetchJson(view: View) { val client = OkHttpClient() @@ -344,6 +345,22 @@ class PlayerFragment : Fragment() { val dialog: AlertDialog? = builder?.create() dialog?.show() } + exoPlayer!!.addListener(object : com.google.android.exoplayer2.Player.Listener { + override fun onPlayerStateChanged(playWhenReady: Boolean,playbackState: Int) { + if (playWhenReady && playbackState == Player.STATE_READY) { + // media actually playing + view.findViewById(R.id.play_imageView).setImageResource(R.drawable.ic_pause) + } else if (playWhenReady) { + // might be idle (plays after prepare()), + // buffering (plays when data available) + // or ended (plays when seek away from end) + view.findViewById(R.id.play_imageView).setImageResource(R.drawable.ic_play) + } else { + // player paused in any state + view.findViewById(R.id.play_imageView).setImageResource(R.drawable.ic_play) + } + } + }) } } @@ -375,6 +392,5 @@ class PlayerFragment : Fragment() { override fun onResume() { super.onResume() - println("wtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtf") } } \ No newline at end of file diff --git a/app/src/main/res/layout-land/fragment_player.xml b/app/src/main/res/layout-land/fragment_player.xml deleted file mode 100644 index 3bb0c7aec..000000000 --- a/app/src/main/res/layout-land/fragment_player.xml +++ /dev/null @@ -1,108 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file