狀態加上緩衝中
This commit is contained in:
parent
0a65a9615b
commit
cdd2c3775d
@ -125,6 +125,7 @@ class VideoView : ConstraintLayout, SurfaceHolder.Callback, GstCallback {
|
||||
GstStatus.PLAYING -> mHandler.sendMessage(Message().apply { what = MSG_PLAY })
|
||||
GstStatus.PAUSE -> mHandler.sendMessage(Message().apply { what = MSG_PAUSE })
|
||||
GstStatus.ERROR_WHEN_OPENING -> mHandler.sendMessage(Message().apply { what = MSG_PAUSE })
|
||||
GstStatus.BUFFERING -> mHandler.sendMessage(Message().apply { what = MSG_BUFFERING })
|
||||
else -> {}
|
||||
}
|
||||
Log.e("${TAG}_$tag", "onStatus: $gstStatus")
|
||||
@ -145,6 +146,10 @@ class VideoView : ConstraintLayout, SurfaceHolder.Callback, GstCallback {
|
||||
isLoading = false
|
||||
isPlaying = true
|
||||
}
|
||||
MSG_BUFFERING -> {
|
||||
isLoading = true
|
||||
isPlaying = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -157,6 +162,6 @@ class VideoView : ConstraintLayout, SurfaceHolder.Callback, GstCallback {
|
||||
|
||||
private const val MSG_PAUSE = 1
|
||||
private const val MSG_PLAY = 2
|
||||
|
||||
private const val MSG_BUFFERING = 3
|
||||
}
|
||||
}
|
||||
@ -76,7 +76,7 @@ public class GstLibrary implements Closeable {
|
||||
if (gstCallback == null) return;
|
||||
if (message.contains("State changed to PAUSED")) {
|
||||
gstCallback.onStatus(GstStatus.PAUSE);
|
||||
} else if (message.contains("State changed to PLAYING")) {
|
||||
} else if (message.contains("State changed to PLAYING") || message.contains("Buffering complete")) {
|
||||
gstCallback.onStatus(GstStatus.PLAYING);
|
||||
} else if (message.contains("Could not open resource for reading and writing")) {
|
||||
gstCallback.onStatus(GstStatus.ERROR_WHEN_OPENING);
|
||||
@ -84,6 +84,8 @@ public class GstLibrary implements Closeable {
|
||||
gstCallback.onStatus(GstStatus.ERROR);
|
||||
} else if (message.contains("Unhandled error")) {
|
||||
gstCallback.onStatus(GstStatus.ERROR);
|
||||
} else if (message.contains("Buffering")) {
|
||||
gstCallback.onStatus(GstStatus.BUFFERING);
|
||||
}
|
||||
gstCallback.onMessage(message);
|
||||
}
|
||||
|
||||
@ -5,5 +5,6 @@ public enum GstStatus {
|
||||
PAUSE,
|
||||
PLAYING,
|
||||
ERROR,
|
||||
ERROR_WHEN_OPENING
|
||||
ERROR_WHEN_OPENING,
|
||||
BUFFERING
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user