初步測試多畫面
This commit is contained in:
parent
735958bdb0
commit
f26e095026
@ -3,7 +3,7 @@
|
||||
<component name="DesignSurface">
|
||||
<option name="filePathToZoomLevelMap">
|
||||
<map>
|
||||
<entry key="..\:/Users/hisharp/Downloads/gstreamer-main/Gstreamer/app/src/main/res/layout/activity_main.xml" value="0.16574074074074074" />
|
||||
<entry key="..\:/Users/hisharp/Downloads/gstreamer-main/Gstreamer/app/src/main/res/layout/activity_main.xml" value="0.33" />
|
||||
<entry key="..\:/Users/hisharp/Downloads/gstreamer-main/Gstreamer/gstreamer_player/res/layout/main.xml" value="0.16574074074074074" />
|
||||
<entry key="..\:/Users/hisharp/Downloads/gstreamer-main/android/android-tutorial-5/res/layout/main.xml" value="0.1" />
|
||||
<entry key="..\:/Users/hisharp/Downloads/gstreamer-main/android/android-tutorial-6/res/layout/confmanager.xml" value="0.1" />
|
||||
@ -12,5 +12,5 @@
|
||||
</option>
|
||||
</component>
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_16_PREVIEW" project-jdk-name="16" project-jdk-type="JavaSDK" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_16" project-jdk-name="16" project-jdk-type="JavaSDK" />
|
||||
</project>
|
||||
@ -34,6 +34,7 @@ dependencies {
|
||||
implementation 'androidx.appcompat:appcompat:1.0.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
implementation project(path: ':gstreamer_player')
|
||||
implementation 'androidx.gridlayout:gridlayout:1.0.0'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
|
||||
|
||||
@ -5,20 +5,38 @@ import android.util.Log;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.hisharp.gstreamer_player.GStreamerSurfaceView;
|
||||
import com.hisharp.gstreamer_player.GstCallback;
|
||||
import com.hisharp.gstreamer_player.GstLibrary;
|
||||
import com.hisharp.gstreamer_player.GstStatus;
|
||||
import com.ray650128.gstreamer_demo_app.databinding.ActivityMainBinding;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class MainActivity extends AppCompatActivity implements GstCallback {
|
||||
|
||||
private String TAG = MainActivity.class.getSimpleName();
|
||||
|
||||
private ActivityMainBinding binding;
|
||||
|
||||
private GstLibrary gstLibrary;
|
||||
//private GstLibrary gstLibrary;
|
||||
|
||||
private final String defaultMediaUri = "rtsp://admin:admin@192.168.0.77:554/media/video2";
|
||||
//private final String defaultMediaUri = "rtsp://admin:admin@192.168.0.77:554/media/video2";
|
||||
|
||||
private final ArrayList<GstLibrary> gstLibraries = new ArrayList();
|
||||
private final String[] defaultMediaUris = {
|
||||
"rtsp://admin:admin@192.168.0.77:554/media/video2",
|
||||
"rtsp://admin:123456@192.168.0.80:554/profile2",
|
||||
"rtsp://admin:123456@192.168.0.83:554/profile2",
|
||||
"rtsp://admin:123456@192.168.0.84:554/profile2",
|
||||
"rtsp://admin:admin@192.168.0.86:554/v2",
|
||||
"rtsp://admin:admin@192.168.0.89:554/v02",
|
||||
"rtsp://admin:1q2w3e4r!@60.249.32.50:554/unicast/c7/s1/live",
|
||||
"rtsp://admin:1q2w3e4r!@60.249.32.50:554/unicast/c8/s1/live",
|
||||
"rtsp://admin:1q2w3e4r!@60.249.32.50:554/unicast/c9/s1/live"
|
||||
};
|
||||
|
||||
private final ArrayList<GStreamerSurfaceView> videoViews = new ArrayList();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -26,30 +44,59 @@ public class MainActivity extends AppCompatActivity implements GstCallback {
|
||||
binding = ActivityMainBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
gstLibrary = new GstLibrary(this, defaultMediaUri);
|
||||
videoViews.add(binding.surfaceVideo1);
|
||||
videoViews.add(binding.surfaceVideo2);
|
||||
videoViews.add(binding.surfaceVideo3);
|
||||
videoViews.add(binding.surfaceVideo4);
|
||||
videoViews.add(binding.surfaceVideo5);
|
||||
videoViews.add(binding.surfaceVideo6);
|
||||
videoViews.add(binding.surfaceVideo7);
|
||||
videoViews.add(binding.surfaceVideo8);
|
||||
videoViews.add(binding.surfaceVideo9);
|
||||
|
||||
gstLibrary.setSurfaceView(binding.surfaceVideo);
|
||||
for (int i = 0; i < 1; i++) {
|
||||
gstLibraries.add(new GstLibrary(this, defaultMediaUris[i]));
|
||||
gstLibraries.get(i).setSurfaceView(videoViews.get(i));
|
||||
gstLibraries.get(i).setOnStatusChangeListener(this);
|
||||
}
|
||||
|
||||
binding.buttonPlay.setOnClickListener(view -> gstLibraries.forEach(GstLibrary::play));
|
||||
|
||||
binding.buttonStop.setOnClickListener(view -> gstLibraries.forEach(GstLibrary::stop));
|
||||
|
||||
/*gstLibrary = new GstLibrary(this, defaultMediaUri);
|
||||
|
||||
gstLibrary.setSurfaceView(binding.surfaceVideo1);
|
||||
gstLibrary.setOnStatusChangeListener(this);
|
||||
|
||||
binding.buttonPlay.setOnClickListener(view -> gstLibrary.play());
|
||||
|
||||
binding.buttonStop.setOnClickListener(view -> gstLibrary.stop());
|
||||
binding.buttonStop.setOnClickListener(view -> gstLibrary.stop());*/
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
|
||||
if (gstLibrary != null) {
|
||||
/*if (gstLibrary != null) {
|
||||
gstLibrary.stop();
|
||||
}*/
|
||||
|
||||
if (!gstLibraries.isEmpty()) {
|
||||
gstLibraries.forEach(GstLibrary::stop);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (gstLibrary != null) {
|
||||
|
||||
/*if (gstLibrary != null) {
|
||||
gstLibrary.release();
|
||||
}*/
|
||||
|
||||
if (!gstLibraries.isEmpty()) {
|
||||
gstLibraries.forEach(GstLibrary::release);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
@ -37,10 +38,83 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.hisharp.gstreamer_player.GStreamerSurfaceView
|
||||
android:id="@+id/surface_video"
|
||||
<androidx.gridlayout.widget.GridLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|center_horizontal" />
|
||||
android:layout_gravity="center"
|
||||
app:columnCount="3"
|
||||
app:rowCount="3">
|
||||
|
||||
<com.hisharp.gstreamer_player.GStreamerSurfaceView
|
||||
android:id="@+id/surface_video1"
|
||||
android:layout_width="135dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="1dp"
|
||||
android:layout_marginBottom="1dp" />
|
||||
|
||||
<com.hisharp.gstreamer_player.GStreamerSurfaceView
|
||||
android:id="@+id/surface_video2"
|
||||
android:layout_width="135dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="1dp"
|
||||
android:layout_marginEnd="1dp"
|
||||
android:layout_marginBottom="1dp" />
|
||||
|
||||
<com.hisharp.gstreamer_player.GStreamerSurfaceView
|
||||
android:id="@+id/surface_video3"
|
||||
android:layout_width="135dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="1dp"
|
||||
android:layout_marginBottom="1dp" />
|
||||
|
||||
<com.hisharp.gstreamer_player.GStreamerSurfaceView
|
||||
android:id="@+id/surface_video4"
|
||||
android:layout_width="135dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="1dp"
|
||||
android:layout_marginEnd="1dp"
|
||||
android:layout_marginBottom="1dp" />
|
||||
|
||||
<com.hisharp.gstreamer_player.GStreamerSurfaceView
|
||||
android:id="@+id/surface_video5"
|
||||
android:layout_width="135dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="1dp"
|
||||
android:layout_marginStart="1dp"
|
||||
android:layout_marginTop="1dp"
|
||||
android:layout_marginEnd="1dp"
|
||||
android:layout_marginBottom="1dp" />
|
||||
|
||||
<com.hisharp.gstreamer_player.GStreamerSurfaceView
|
||||
android:id="@+id/surface_video6"
|
||||
android:layout_width="135dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="1dp"
|
||||
android:layout_marginTop="1dp"
|
||||
android:layout_marginBottom="1dp" />
|
||||
|
||||
<com.hisharp.gstreamer_player.GStreamerSurfaceView
|
||||
android:id="@+id/surface_video7"
|
||||
android:layout_width="135dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="1dp"
|
||||
android:layout_marginEnd="1dp" />
|
||||
|
||||
<com.hisharp.gstreamer_player.GStreamerSurfaceView
|
||||
android:id="@+id/surface_video8"
|
||||
android:layout_width="135dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="1dp"
|
||||
android:layout_marginStart="1dp"
|
||||
android:layout_marginTop="1dp"
|
||||
android:layout_marginEnd="1dp" />
|
||||
|
||||
<com.hisharp.gstreamer_player.GStreamerSurfaceView
|
||||
android:id="@+id/surface_video9"
|
||||
android:layout_width="135dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="1dp"
|
||||
android:layout_marginTop="1dp" />
|
||||
</androidx.gridlayout.widget.GridLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user