Browse Source

Recording working but only on camera detection

bk_master_copy
Bastian Kohler 1 year ago
parent
commit
bd8371d96d

+ 13
- 0
app/src/main/java/com/example/ueberwachungssystem/Detection/DetectorService.java View File

@Override @Override
public void onDetection(@NonNull DetectionReport detectionReport) { public void onDetection(@NonNull DetectionReport detectionReport) {
//passToServiceListener(detectionReport); //passToServiceListener(detectionReport);

if(detectionReport.detectionState){
detectedVideo = true;
videoDetector.startRecording();
} else {
detectedVideo = false;
if(!(detectedVideo || detectedAudio || detectedMotion)) {
videoDetector.stopRecording();
}
}

wifiCommunication.sendTrue(detectionReport.toMessage()); wifiCommunication.sendTrue(detectionReport.toMessage());


} }
}); });
/** Motion Detection**/ /** Motion Detection**/

+ 1
- 1
app/src/main/java/com/example/ueberwachungssystem/Detection/VideoDetector.java View File

if (isRecording){ if (isRecording){
return; return;
} }
Toast.makeText(context, "video recording started", Toast.LENGTH_SHORT).show();
videoCapture = setupVideoCapture(); videoCapture = setupVideoCapture();


final ListenableFuture<ProcessCameraProvider> cameraProviderFuture = ProcessCameraProvider.getInstance(context); final ListenableFuture<ProcessCameraProvider> cameraProviderFuture = ProcessCameraProvider.getInstance(context);

+ 17
- 0
app/src/main/java/com/example/ueberwachungssystem/Fragments/VideoListFragment.java View File

import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView; import android.widget.ListView;
import android.widget.PopupWindow; import android.widget.PopupWindow;
import android.widget.Toast; import android.widget.Toast;
public class VideoListFragment extends Fragment { public class VideoListFragment extends Fragment {


private ListView listView; private ListView listView;
private Button button;
private ArrayAdapter<String> adapter; private ArrayAdapter<String> adapter;


@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.videolist_fragment, container, false); View rootView = inflater.inflate(R.layout.videolist_fragment, container, false);



button = rootView.findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
File dir = getContext().getFilesDir();
File[] files = dir.listFiles();
for (File file: files) {
file.delete();
}
}
});



listView = rootView.findViewById(R.id.listView); listView = rootView.findViewById(R.id.listView);
adapter = new ArrayAdapter<>(requireContext(), android.R.layout.simple_list_item_1, getFileNames()); adapter = new ArrayAdapter<>(requireContext(), android.R.layout.simple_list_item_1, getFileNames());
listView.setAdapter(adapter); listView.setAdapter(adapter);

+ 9
- 0
app/src/main/res/layout/videolist_fragment.xml View File

<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_height = "wrap_content" android:layout_height = "wrap_content"
tools:ignore="MissingConstraints" /> tools:ignore="MissingConstraints" />


<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Aufnahmen Löschen"
app:layout_constraintBottom_toBottomOf="parent"
tools:ignore="MissingConstraints" />

</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

+ 2
- 3
app/src/main/res/layout/videolist_popup.xml View File

<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingVertical="100dp">
android:layout_height="match_parent">


<VideoView <VideoView
android:id="@+id/videoView" android:id="@+id/videoView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="center_vertical"/>
android:layout_gravity="center"/>


</FrameLayout> </FrameLayout>

Loading…
Cancel
Save