diff --git a/app/src/main/java/com/ray650128/gstreamer_demo_app/GridVideoFragment.kt b/app/src/main/java/com/ray650128/gstreamer_demo_app/GridVideoFragment.kt index 7def1d5..f4ed685 100644 --- a/app/src/main/java/com/ray650128/gstreamer_demo_app/GridVideoFragment.kt +++ b/app/src/main/java/com/ray650128/gstreamer_demo_app/GridVideoFragment.kt @@ -1,6 +1,5 @@ package com.ray650128.gstreamer_demo_app -import android.graphics.Color import android.os.Bundle import android.util.DisplayMetrics import android.util.Log @@ -184,6 +183,8 @@ class GridVideoFragment : Fragment(), GstCallback { when (gstStatus) { GstStatus.PAUSE -> videoViews[index].isPlaying = false GstStatus.PLAYING -> videoViews[index].isPlaying = true + GstStatus.ERROR_WHEN_OPENING -> videoViews[index].isPlaying = false + GstStatus.ERROR -> videoViews[index].isPlaying = false else -> {} } Log.d("${TAG}_$mPageNum", "GstPlayer #$index status: $gstStatus") diff --git a/gstreamer_player/src/com/hisharp/gstreamer_player/GstLibrary.java b/gstreamer_player/src/com/hisharp/gstreamer_player/GstLibrary.java index c980760..870a916 100644 --- a/gstreamer_player/src/com/hisharp/gstreamer_player/GstLibrary.java +++ b/gstreamer_player/src/com/hisharp/gstreamer_player/GstLibrary.java @@ -41,7 +41,6 @@ public class GstLibrary implements SurfaceHolder.Callback { private native void nativeFinalize(); // Destroy pipeline and shutdown native code private native void nativeSetUri(String uri); // Set the URI of the media to play private native void nativePlay(); // Set pipeline to PLAYING - private native void nativeSetPosition(int milliseconds); // Seek to the indicated position, in milliseconds private native void nativePause(); // Set pipeline to PAUSED private static native boolean nativeClassInit(); // Initialize native class: cache Method IDs for callbacks private native void nativeSurfaceInit(Object surface); // A new surface is available @@ -81,6 +80,10 @@ public class GstLibrary implements SurfaceHolder.Callback { } 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_WHEN_OPENING); + } else if (message.contains("GStreamer encountered a general supporting library error")) { + gstCallback.onStatus(this, GstStatus.ERROR); + } else if (message.contains("Unhandled error")) { gstCallback.onStatus(this, GstStatus.ERROR); } gstCallback.onMessage(this, message); @@ -97,12 +100,8 @@ public class GstLibrary implements SurfaceHolder.Callback { // Restore previous playing state nativeSetUri (rtspUrl); - nativeSetPosition (0); } - // 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) { @@ -122,8 +121,7 @@ public class GstLibrary implements SurfaceHolder.Callback { public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { - Log.d("GStreamer", "Surface changed to format " + format + " width " - + width + " height " + height); + Log.d("GStreamer", "Surface changed to format " + format + " width " + width + " height " + height); nativeSurfaceInit (holder.getSurface()); } diff --git a/gstreamer_player/src/com/hisharp/gstreamer_player/GstStatus.java b/gstreamer_player/src/com/hisharp/gstreamer_player/GstStatus.java index e511276..2d687fc 100644 --- a/gstreamer_player/src/com/hisharp/gstreamer_player/GstStatus.java +++ b/gstreamer_player/src/com/hisharp/gstreamer_player/GstStatus.java @@ -4,5 +4,6 @@ public enum GstStatus { READY, PAUSE, PLAYING, - ERROR + ERROR, + ERROR_WHEN_OPENING }