@capgo/camera-preview 8.1.1 → 8.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Package.swift ADDED
@@ -0,0 +1,28 @@
1
+ // swift-tools-version: 5.9
2
+ import PackageDescription
3
+
4
+ let package = Package(
5
+ name: "CapgoCameraPreview",
6
+ platforms: [.iOS(.v15)],
7
+ products: [
8
+ .library(
9
+ name: "CapgoCameraPreview",
10
+ targets: ["CapgoCameraPreview"])
11
+ ],
12
+ dependencies: [
13
+ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0")
14
+ ],
15
+ targets: [
16
+ .target(
17
+ name: "CapgoCameraPreview",
18
+ dependencies: [
19
+ .product(name: "Capacitor", package: "capacitor-swift-pm"),
20
+ .product(name: "Cordova", package: "capacitor-swift-pm")
21
+ ],
22
+ path: "ios/Sources/CapgoCameraPreviewPlugin"),
23
+ .testTarget(
24
+ name: "CapgoCameraPreviewTests",
25
+ dependencies: ["CapgoCameraPreview"],
26
+ path: "ios/Tests/CameraPreviewPluginTests")
27
+ ]
28
+ )
@@ -976,6 +976,15 @@ extension CameraController {
976
976
  captureSession.sessionPreset = desiredPreset
977
977
  }
978
978
 
979
+ // Re-attach movie file output so its connection is bound to the new input.
980
+ if let fileVideoOutput = self.fileVideoOutput,
981
+ captureSession.outputs.contains(where: { $0 === fileVideoOutput }) {
982
+ captureSession.removeOutput(fileVideoOutput)
983
+ if captureSession.canAddOutput(fileVideoOutput) {
984
+ captureSession.addOutput(fileVideoOutput)
985
+ }
986
+ }
987
+
979
988
  // Keep orientation correct
980
989
  self.updateVideoOrientation()
981
990
  }
@@ -2200,6 +2209,20 @@ extension CameraController {
2200
2209
  throw CameraControllerError.fileVideoOutputNotFound
2201
2210
  }
2202
2211
 
2212
+ // Ensure audio session is configured for recording before starting a movie,
2213
+ // only when we are actually recording audio (disableAudio was false).
2214
+ // This reclaims the microphone even if other parts of the app changed the
2215
+ // AVAudioSession category (e.g. for UI sound effects) between recordings.
2216
+ if self.audioInput != nil {
2217
+ do {
2218
+ let audioSession = AVAudioSession.sharedInstance()
2219
+ try audioSession.setCategory(.playAndRecord, mode: .videoRecording, options: [.defaultToSpeaker])
2220
+ try audioSession.setActive(true)
2221
+ } catch {
2222
+ print("[CameraPreview] Failed to configure AVAudioSession for video recording: \(error)")
2223
+ }
2224
+ }
2225
+
2203
2226
  // Ensure the movie file output is attached to the active session.
2204
2227
  // If the camera was started without cameraMode=true, the output may not have been added yet.
2205
2228
  if !captureSession.outputs.contains(where: { $0 === fileVideoOutput }) {
@@ -2213,12 +2236,17 @@ extension CameraController {
2213
2236
  captureSession.commitConfiguration()
2214
2237
  }
2215
2238
 
2216
- // cpcp_video_A6C01203 - portrait
2217
- //
2218
2239
  if let connection = fileVideoOutput.connection(with: .video) {
2219
2240
  if connection.isEnabled == false { connection.isEnabled = true }
2220
2241
  // Goes off accelerometer now
2221
2242
  connection.videoOrientation = self.getPhysicalOrientation()
2243
+
2244
+ // Front camera: mirror the recorded video so it looks natural (selfie style).
2245
+ if self.currentCameraPosition == .front, connection.isVideoMirroringSupported {
2246
+ connection.isVideoMirrored = true
2247
+ } else {
2248
+ connection.isVideoMirrored = false
2249
+ }
2222
2250
  }
2223
2251
 
2224
2252
  let identifier = UUID()
@@ -34,7 +34,7 @@ extension UIWindow {
34
34
  */
35
35
  @objc(CameraPreview)
36
36
  public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelegate {
37
- private let pluginVersion: String = "8.1.1"
37
+ private let pluginVersion: String = "8.1.3"
38
38
  public let identifier = "CameraPreviewPlugin"
39
39
  public let jsName = "CameraPreview"
40
40
  public let pluginMethods: [CAPPluginMethod] = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/camera-preview",
3
- "version": "8.1.1",
3
+ "version": "8.1.3",
4
4
  "description": "Camera preview",
5
5
  "license": "MPL-2.0",
6
6
  "repository": {
@@ -31,6 +31,7 @@
31
31
  "types": "dist/esm/index.d.ts",
32
32
  "files": [
33
33
  "CapgoCameraPreview.podspec",
34
+ "Package.swift",
34
35
  "android/",
35
36
  "dist/",
36
37
  "ios/"