實作播放器狀態判斷

This commit is contained in:
Barney 2022-08-05 14:37:49 +08:00
parent 97cac9ba9a
commit 7c567944db
8 changed files with 26 additions and 1 deletions

View File

@ -185,7 +185,13 @@ class GridVideoFragment : Fragment(), GstCallback {
}
override fun onStatus(gstInstance: GstLibrary, gstStatus: GstStatus?) {
//Log.d(TAG, GstStatus.values());
val index = gstPlayers.indexOf(gstInstance)
when (gstStatus) {
GstStatus.PAUSE -> videoViews[index].isPlaying = false
GstStatus.PLAYING -> videoViews[index].isPlaying = true
else -> {}
}
Log.d("${TAG}_$mPageNum", "GstPlayer #$index status: $gstStatus")
}
override fun onMessage(gstInstance: GstLibrary, message: String?) {

View File

@ -4,6 +4,7 @@ import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.isVisible
import com.hisharp.gstreamer_player.GStreamerSurfaceView
import com.ray650128.gstreamer_demo_app.databinding.ItemVideoViewBinding
@ -23,6 +24,12 @@ class VideoView : ConstraintLayout {
private lateinit var view: ItemVideoViewBinding
var isPlaying: Boolean = false
set(value) {
view.imgPause.isVisible = !value
field = value
}
val videoView: GStreamerSurfaceView by lazy { view.videoView }
private fun initView(context: Context) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

View File

@ -17,6 +17,18 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/imgPause"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="fitXY"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/bg_not_in_playing" />
<ProgressBar
android:id="@+id/pbLoading"
style="?android:attr/progressBarStyle"