mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-27 15:30:31 +05:30
Fixed Play and pause in motion problem
This commit is contained in:
parent
d7f6eb3f29
commit
9a5bb5aac8
23
.idea/deploymentTargetDropDown.xml
generated
23
.idea/deploymentTargetDropDown.xml
generated
@ -1,6 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetDropDown">
|
||||
<runningDeviceTargetSelectedWithDropDown>
|
||||
<Target>
|
||||
<type value="RUNNING_DEVICE_TARGET" />
|
||||
<deviceKey>
|
||||
<Key>
|
||||
<type value="VIRTUAL_DEVICE_PATH" />
|
||||
<value value="$USER_HOME$/.android/avd/Pixel_5_API_29.avd" />
|
||||
</Key>
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</runningDeviceTargetSelectedWithDropDown>
|
||||
<targetSelectedWithDropDown>
|
||||
<Target>
|
||||
<type value="QUICK_BOOT_TARGET" />
|
||||
<deviceKey>
|
||||
<Key>
|
||||
<type value="VIRTUAL_DEVICE_PATH" />
|
||||
<value value="$USER_HOME$/.android/avd/Pixel_5_API_29.avd" />
|
||||
</Key>
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</targetSelectedWithDropDown>
|
||||
<timeTargetWasSelectedWithDropDown value="2021-12-17T12:12:37.849691Z" />
|
||||
<runningDeviceTargetsSelectedWithDialog>
|
||||
<Target>
|
||||
<type value="RUNNING_DEVICE_TARGET" />
|
||||
|
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
@ -17,6 +17,7 @@
|
||||
<entry key="app/src/main/res/layout/styled_quality_list_item.xml" value="0.15520833333333334" />
|
||||
<entry key="app/src/main/res/layout/trending_row.xml" value="0.33" />
|
||||
<entry key="app/src/main/res/menu/bottom_menu.xml" value="0.15520833333333334" />
|
||||
<entry key="app/src/main/res/xml-land/player_scene.xml" value="0.13139329805996472" />
|
||||
<entry key="app/src/main/res/xml/network_security_config.xml" value="0.15520833333333334" />
|
||||
</map>
|
||||
</option>
|
||||
|
@ -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<FrameLayout>(R.id.container).visibility=View.VISIBLE
|
||||
val playerMotionLayout = view.findViewById<SingleViewTouchableMotionLayout>(R.id.playerMotionLayout)
|
||||
val playerMotionLayout = view.findViewById<MotionLayout>(R.id.playerMotionLayout)
|
||||
motionLayout = playerMotionLayout
|
||||
exoPlayerView = view.findViewById(R.id.player)
|
||||
view.findViewById<TextView>(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<ImageView>(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<ImageView>(R.id.play_imageView).setImageResource(R.drawable.ic_play)
|
||||
} else {
|
||||
// player paused in any state
|
||||
view.findViewById<ImageView>(R.id.play_imageView).setImageResource(R.drawable.ic_play)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -375,6 +392,5 @@ class PlayerFragment : Fragment() {
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
println("wtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtfwtf")
|
||||
}
|
||||
}
|
@ -1,108 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layoutDescription="@xml/player_scene"
|
||||
tools:context=".PlayerFragment"
|
||||
android:background="@android:color/transparent"
|
||||
android:id="@+id/playerMotionLayout"
|
||||
>
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/scrollView2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/main_container"
|
||||
android:background="@color/white"
|
||||
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textTest"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=""
|
||||
|
||||
/>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/main_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="350dp"
|
||||
android:background="#FFFFFF"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<xyz.btcland.libretube.CustomExoPlayerView
|
||||
android:id="@+id/player"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:scaleType="centerCrop"
|
||||
app:layout_constraintBottom_toBottomOf="@id/main_container"
|
||||
app:layout_constraintStart_toStartOf="@id/main_container"
|
||||
app:layout_constraintTop_toTopOf="@id/main_container"
|
||||
app:show_buffering="always"
|
||||
android:background="@color/black"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/close_imageView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:alpha="0"
|
||||
app:layout_constraintBottom_toBottomOf="@id/main_container"
|
||||
app:layout_constraintEnd_toEndOf="@id/main_container"
|
||||
app:layout_constraintTop_toTopOf="@id/main_container"
|
||||
android:src="@drawable/ic_close"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/play_imageView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:alpha="0"
|
||||
android:src="@drawable/ic_play"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/close_imageView"
|
||||
app:layout_constraintEnd_toStartOf="@+id/close_imageView"
|
||||
app:layout_constraintTop_toTopOf="@+id/close_imageView"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title_textView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:alpha="0"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/play_imageView"
|
||||
app:layout_constraintEnd_toStartOf="@+id/play_imageView"
|
||||
app:layout_constraintStart_toEndOf="@+id/player"
|
||||
app:layout_constraintTop_toTopOf="@+id/play_imageView"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
</androidx.constraintlayout.motion.widget.MotionLayout>
|
Loading…
x
Reference in New Issue
Block a user