實作播放器狀態判斷
This commit is contained in:
parent
97cac9ba9a
commit
7c567944db
@ -185,7 +185,13 @@ class GridVideoFragment : Fragment(), GstCallback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onStatus(gstInstance: GstLibrary, gstStatus: GstStatus?) {
|
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?) {
|
override fun onMessage(gstInstance: GstLibrary, message: String?) {
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import android.content.Context
|
|||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import com.hisharp.gstreamer_player.GStreamerSurfaceView
|
import com.hisharp.gstreamer_player.GStreamerSurfaceView
|
||||||
import com.ray650128.gstreamer_demo_app.databinding.ItemVideoViewBinding
|
import com.ray650128.gstreamer_demo_app.databinding.ItemVideoViewBinding
|
||||||
|
|
||||||
@ -23,6 +24,12 @@ class VideoView : ConstraintLayout {
|
|||||||
|
|
||||||
private lateinit var view: ItemVideoViewBinding
|
private lateinit var view: ItemVideoViewBinding
|
||||||
|
|
||||||
|
var isPlaying: Boolean = false
|
||||||
|
set(value) {
|
||||||
|
view.imgPause.isVisible = !value
|
||||||
|
field = value
|
||||||
|
}
|
||||||
|
|
||||||
val videoView: GStreamerSurfaceView by lazy { view.videoView }
|
val videoView: GStreamerSurfaceView by lazy { view.videoView }
|
||||||
|
|
||||||
private fun initView(context: Context) {
|
private fun initView(context: Context) {
|
||||||
|
|||||||
BIN
app/src/main/res/drawable-ldpi/bg_not_in_playing.png
Normal file
BIN
app/src/main/res/drawable-ldpi/bg_not_in_playing.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.9 KiB |
BIN
app/src/main/res/drawable-xhdpi/bg_not_in_playing.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/bg_not_in_playing.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
BIN
app/src/main/res/drawable-xxhdpi/bg_not_in_playing.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/bg_not_in_playing.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/bg_not_in_playing.png
Normal file
BIN
app/src/main/res/drawable-xxxhdpi/bg_not_in_playing.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
BIN
app/src/main/res/drawable/bg_not_in_playing.png
Normal file
BIN
app/src/main/res/drawable/bg_not_in_playing.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.7 KiB |
@ -17,6 +17,18 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="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
|
<ProgressBar
|
||||||
android:id="@+id/pbLoading"
|
android:id="@+id/pbLoading"
|
||||||
style="?android:attr/progressBarStyle"
|
style="?android:attr/progressBarStyle"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user