Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Prev Previous commit
Next Next commit
Testing
  • Loading branch information
camsim99 committed May 24, 2022
commit bb17f4825c94a41cff385d5b2545ff4789851a33
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public void onClosed(@NonNull CameraDevice camera) {

// Prevents calls to methods that would otherwise result in IllegalStateException exceptions.
cameraDevice = null;
captureSession = null;
closeCaptureSession();
dartMessenger.sendCameraClosingEvent();
}

Expand All @@ -356,8 +356,9 @@ public void onDisconnected(@NonNull CameraDevice cameraDevice) {
@Override
public void onError(@NonNull CameraDevice cameraDevice, int errorCode) {
Log.i(TAG, "open | onError");

close();

String errorDescription;
switch (errorCode) {
case ERROR_CAMERA_IN_USE:
Expand Down Expand Up @@ -393,7 +394,7 @@ private void createCaptureSession(
int templateType, Runnable onSuccessCallback, Surface... surfaces)
throws CameraAccessException {
// Close any existing capture session.
captureSession = null;
closeCaptureSession();

// Create a new capture builder.
previewRequestBuilder = cameraDevice.createCaptureRequest(templateType);
Expand Down Expand Up @@ -1169,6 +1170,15 @@ private void setImageStreamImageAvailableListener(final EventChannel.EventSink i
backgroundHandler);
}

private void closeCaptureSession() {
if (captureSession != null) {
Log.i(TAG, "closeCaptureSession");

captureSession.close();
captureSession = null;
}
}

public void close() {
Log.i(TAG, "close");
captureSession = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ void sendCameraClosingEvent() {
* @param description contains details regarding the error that occurred.
*/
void sendCameraErrorEvent(@Nullable String description) {
System.out.println("!!!!!!!!!!!!!!!!!!!!Sending error camera event: " + description);
this.send(
CameraEventType.ERROR,
new HashMap<String, Object>() {
Expand All @@ -157,6 +158,7 @@ private void send(CameraEventType eventType, Map<String, Object> args) {
@Override
public void run() {
cameraChannel.invokeMethod(eventType.method, args);
System.out.println("!!!!!!!!!!!!!!Sending message across channel");
}
});
}
Expand Down
6 changes: 4 additions & 2 deletions packages/camera/camera/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ flutter:
default_package: camera_web

dependencies:
camera_platform_interface: ^2.1.0
camera_web: ^0.2.1
camera_platform_interface:
path: ../camera_platform_interface/
camera_web:
path: ../camera_web/
flutter:
sdk: flutter
flutter_plugin_android_lifecycle: ^2.0.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ class MethodChannelCamera extends CameraPlatform {
));
break;
case 'error':
print("!!!!!!!!!!!!!!!error found");
cameraEventStreamController.add(CameraErrorEvent(
cameraId,
call.arguments['description']! as String,
Expand Down
3 changes: 2 additions & 1 deletion packages/camera/camera_web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ flutter:
fileName: camera_web.dart

dependencies:
camera_platform_interface: ^2.1.0
camera_platform_interface:
path: ../camera_platform_interface/
flutter:
sdk: flutter
flutter_web_plugins:
Expand Down