GstLibrary加上錯誤狀態
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package com.hisharp.gstreamer_player;
|
||||
|
||||
public interface GstCallback {
|
||||
public void onStatus(GstLibrary gstInstance, GstStatus gstStatus);
|
||||
public void onMessage(GstLibrary gstInstance, String message);
|
||||
public void onMediaSizeChanged (GstLibrary gstInstance, int width, int height);
|
||||
void onStatus(GstLibrary gstInstance, GstStatus gstStatus);
|
||||
void onMessage(GstLibrary gstInstance, String message);
|
||||
}
|
||||
|
||||
@@ -80,6 +80,8 @@ public class GstLibrary implements SurfaceHolder.Callback {
|
||||
gstCallback.onStatus(this, GstStatus.PAUSE);
|
||||
} else if (message.contains("State changed to PLAYING")) {
|
||||
gstCallback.onStatus(this, GstStatus.PLAYING);
|
||||
} else if (message.contains("Could not open resource for reading and writing")) {
|
||||
gstCallback.onStatus(this, GstStatus.ERROR);
|
||||
}
|
||||
gstCallback.onMessage(this, message);
|
||||
}
|
||||
@@ -101,6 +103,17 @@ public class GstLibrary implements SurfaceHolder.Callback {
|
||||
// Called from native code
|
||||
private void setCurrentPosition(final int position, final int duration) {}
|
||||
|
||||
// Called from native code when the size of the media changes or is first detected.
|
||||
// Inform the video surface about the new size and recalculate the layout.
|
||||
private void onMediaSizeChanged (int width, int height) {
|
||||
Log.i ("GStreamer", "Media size changed to " + width + "x" + height);
|
||||
mainHandler.post(() -> {
|
||||
surfaceView.media_width = width;
|
||||
surfaceView.media_height = height;
|
||||
surfaceView.requestLayout();
|
||||
});
|
||||
}
|
||||
|
||||
static {
|
||||
System.loadLibrary("gstreamer_android");
|
||||
System.loadLibrary("gst_player");
|
||||
@@ -122,16 +135,4 @@ public class GstLibrary implements SurfaceHolder.Callback {
|
||||
Log.d("GStreamer", "Surface destroyed");
|
||||
nativeSurfaceFinalize();
|
||||
}
|
||||
|
||||
// Called from native code when the size of the media changes or is first detected.
|
||||
// Inform the video surface about the new size and recalculate the layout.
|
||||
private void onMediaSizeChanged (int width, int height) {
|
||||
Log.i ("GStreamer", "Media size changed to " + width + "x" + height);
|
||||
mainHandler.post(() -> {
|
||||
surfaceView.media_width = width;
|
||||
surfaceView.media_height = height;
|
||||
surfaceView.requestLayout();
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@ package com.hisharp.gstreamer_player;
|
||||
public enum GstStatus {
|
||||
READY,
|
||||
PAUSE,
|
||||
PLAYING
|
||||
PLAYING,
|
||||
ERROR
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user