public static void Pause() { switch (Interface) { case NatCamInterface.NativeInterface: Native.Pause(); break; case NatCamInterface.FallbackInterface: Fallback.Pause(); break; } }
public static void Release() { DeviceCamera.Reset(); switch (Interface) { case NatCamInterface.NativeInterface: Native.Release(); break; case NatCamInterface.FallbackInterface: Fallback.Release(); break; } }
public static void Play(DeviceCamera camera = null) { switch (Interface) { case NatCamInterface.NativeInterface: if (camera != null) { Native.mActiveCamera = camera; } Native.Play(); break; case NatCamInterface.FallbackInterface: if (camera != null) { Fallback.mActiveCamera = camera; } Fallback.Play(); break; } }
public static void CapturePhoto(params PhotoCallback[] callbacks) { if (!IsPlaying) { Ext.Warn("Cannot capture photo when session is not running"); return; } if (callbacks.Length == 0 && OnPhotoCapture == null) { Ext.Warn("Cannot capture photo because there is no callback subscribed"); return; } else if (callbacks.Length > 0) { for (int i = 0; i < callbacks.Length; i++) { PhotoCallback callback = callbacks[i]; PhotoCallback captureWrapper = null; captureWrapper = (Texture2D photo) => { if (callback != null) { callback(photo); } OnPhotoCapture -= captureWrapper; }; OnPhotoCapture += captureWrapper; } } if (Interface == NatCamInterface.NativeInterface) { Native.CapturePhoto(); } else { Fallback.CapturePhoto(); } }
public static void Initialize(NatCamInterface NatCamInterface = NatCamInterface.NativeInterface, PreviewType PreviewType = PreviewType.NonReadable, Switch MetadataDetection = Switch.Off) { Interface = NatCamInterface; if (Interface == NatCamInterface.NativeInterface && !IsSupportedDevice) { Ext.Warn("Running on an unsupported platform or a device without cameras. Falling back to Fallback"); Interface = NatCamInterface.FallbackInterface; } switch (Interface) { case NatCamInterface.NativeInterface: Native.Initialize(PreviewType, MetadataDetection == Switch.On); Native.RegisterEvents(PropagateStart, PropagateUpdate, PropagatePhoto, PropagateBarcode, PropagateFace, SetApplicationFocus); break; case NatCamInterface.FallbackInterface: Fallback.Initialize(MetadataDetection == Switch.On); Fallback.RegisterEvents(PropagateStart, PropagateUpdate, PropagatePhoto, PropagateBarcode, PropagateFace, SetApplicationFocus); break; default: goto case NatCamInterface.FallbackInterface; } }