新增錯誤狀態
This commit is contained in:
parent
62503432b0
commit
81c48f7cf2
@ -1,6 +1,5 @@
|
|||||||
package com.ray650128.gstreamer_demo_app
|
package com.ray650128.gstreamer_demo_app
|
||||||
|
|
||||||
import android.graphics.Color
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.DisplayMetrics
|
import android.util.DisplayMetrics
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
@ -184,6 +183,8 @@ class GridVideoFragment : Fragment(), GstCallback {
|
|||||||
when (gstStatus) {
|
when (gstStatus) {
|
||||||
GstStatus.PAUSE -> videoViews[index].isPlaying = false
|
GstStatus.PAUSE -> videoViews[index].isPlaying = false
|
||||||
GstStatus.PLAYING -> videoViews[index].isPlaying = true
|
GstStatus.PLAYING -> videoViews[index].isPlaying = true
|
||||||
|
GstStatus.ERROR_WHEN_OPENING -> videoViews[index].isPlaying = false
|
||||||
|
GstStatus.ERROR -> videoViews[index].isPlaying = false
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
Log.d("${TAG}_$mPageNum", "GstPlayer #$index status: $gstStatus")
|
Log.d("${TAG}_$mPageNum", "GstPlayer #$index status: $gstStatus")
|
||||||
|
|||||||
@ -41,7 +41,6 @@ public class GstLibrary implements SurfaceHolder.Callback {
|
|||||||
private native void nativeFinalize(); // Destroy pipeline and shutdown native code
|
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 nativeSetUri(String uri); // Set the URI of the media to play
|
||||||
private native void nativePlay(); // Set pipeline to PLAYING
|
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 native void nativePause(); // Set pipeline to PAUSED
|
||||||
private static native boolean nativeClassInit(); // Initialize native class: cache Method IDs for callbacks
|
private static native boolean nativeClassInit(); // Initialize native class: cache Method IDs for callbacks
|
||||||
private native void nativeSurfaceInit(Object surface); // A new surface is available
|
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")) {
|
} else if (message.contains("State changed to PLAYING")) {
|
||||||
gstCallback.onStatus(this, GstStatus.PLAYING);
|
gstCallback.onStatus(this, GstStatus.PLAYING);
|
||||||
} else if (message.contains("Could not open resource for reading and writing")) {
|
} 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.onStatus(this, GstStatus.ERROR);
|
||||||
}
|
}
|
||||||
gstCallback.onMessage(this, message);
|
gstCallback.onMessage(this, message);
|
||||||
@ -97,12 +100,8 @@ public class GstLibrary implements SurfaceHolder.Callback {
|
|||||||
|
|
||||||
// Restore previous playing state
|
// Restore previous playing state
|
||||||
nativeSetUri (rtspUrl);
|
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.
|
// 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.
|
// Inform the video surface about the new size and recalculate the layout.
|
||||||
private void onMediaSizeChanged (int width, int height) {
|
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,
|
public void surfaceChanged(SurfaceHolder holder, int format, int width,
|
||||||
int height) {
|
int height) {
|
||||||
Log.d("GStreamer", "Surface changed to format " + format + " width "
|
Log.d("GStreamer", "Surface changed to format " + format + " width " + width + " height " + height);
|
||||||
+ width + " height " + height);
|
|
||||||
nativeSurfaceInit (holder.getSurface());
|
nativeSurfaceInit (holder.getSurface());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,5 +4,6 @@ public enum GstStatus {
|
|||||||
READY,
|
READY,
|
||||||
PAUSE,
|
PAUSE,
|
||||||
PLAYING,
|
PLAYING,
|
||||||
ERROR
|
ERROR,
|
||||||
|
ERROR_WHEN_OPENING
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user