@picsa/capacitor-video-player 7.1.0 → 7.2.2
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/CapacitorVideoPlayer.podspec +17 -17
- package/LICENSE +21 -21
- package/android/build.gradle +71 -71
- package/android/src/main/AndroidManifest.xml +3 -3
- package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/CapacitorVideoPlayer.java +71 -71
- package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/CapacitorVideoPlayerPlugin.java +1256 -1256
- package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/FullscreenExoPlayerFragment.java +1595 -1595
- package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/Notifications/MyRunnable.java +21 -21
- package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/Notifications/NotificationCenter.java +61 -61
- package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/PickerVideo/AdapterVideoList.java +47 -47
- package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/PickerVideo/ModelVideo.java +49 -49
- package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/PickerVideo/PickerVideoFragment.java +119 -119
- package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/PickerVideo/VideoRecyclerViewHolder.java +65 -65
- package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/Utilities/FilesUtils.java +101 -101
- package/android/src/main/java/com/jeep/plugin/capacitor/capacitorvideoplayer/Utilities/FragmentUtils.java +32 -32
- package/android/src/main/res/drawable/bg_round_rect_white_50.xml +9 -9
- package/android/src/main/res/drawable/bg_rounded_rectangle_white_corner_rounded.xml +10 -10
- package/android/src/main/res/drawable/exo_close_btn.xml +11 -11
- package/android/src/main/res/drawable/gradient_transparent_middle.xml +12 -12
- package/android/src/main/res/drawable/ic_arrow_left.xml +5 -5
- package/android/src/main/res/drawable/ic_baseline_lq.xml +7 -7
- package/android/src/main/res/drawable/ic_exo_icon_fastforward.xml +35 -35
- package/android/src/main/res/drawable/ic_exo_icon_pause.xml +26 -26
- package/android/src/main/res/drawable/ic_exo_icon_play.xml +36 -36
- package/android/src/main/res/drawable/ic_exo_icon_rewind.xml +35 -35
- package/android/src/main/res/drawable/ic_expand.xml +5 -5
- package/android/src/main/res/drawable/ic_fit.xml +5 -5
- package/android/src/main/res/drawable/ic_image_background.xml +12 -12
- package/android/src/main/res/drawable/ic_img_16_9_background.xml +10 -10
- package/android/src/main/res/drawable/ic_img_9_16_background.xml +10 -10
- package/android/src/main/res/drawable/ic_outline_lock.xml +5 -5
- package/android/src/main/res/drawable/ic_outline_lock_open.xml +5 -5
- package/android/src/main/res/drawable/ic_pip_white.xml +5 -5
- package/android/src/main/res/drawable/ic_views.xml +18 -18
- package/android/src/main/res/drawable/ic_zoom.xml +5 -5
- package/android/src/main/res/layout/bridge_layout_main.xml +15 -15
- package/android/src/main/res/layout/exo_playback_control_view.xml +289 -289
- package/android/src/main/res/layout/exoplayer_layout_youtube.xml +361 -361
- package/android/src/main/res/layout/fragment_fs_exoplayer.xml +50 -50
- package/android/src/main/res/layout/fragment_picker_video.xml +21 -21
- package/android/src/main/res/layout/row_video.xml +76 -76
- package/android/src/main/res/values/colors.xml +14 -14
- package/android/src/main/res/values/strings.xml +3 -3
- package/android/src/main/res/values/styles.xml +3 -3
- package/dist/docs.json +14 -14
- package/ios/Plugin/CapacitorVideoPlayer.swift +63 -63
- package/ios/Plugin/CapacitorVideoPlayerPlugin.h +10 -10
- package/ios/Plugin/CapacitorVideoPlayerPlugin.m +22 -22
- package/ios/Plugin/CapacitorVideoPlayerPlugin.swift +631 -631
- package/ios/Plugin/Extensions/CapacitorVideoPlayerPlugin.AVPlayerViewController.swift +59 -59
- package/ios/Plugin/Extensions/CapacitorVideoPlayerPlugin.File.swift +126 -126
- package/ios/Plugin/Extensions/CapacitorVideoPlayerPlugin.Fullscreen.swift +94 -94
- package/ios/Plugin/Extensions/CapacitorVideoPlayerPlugin.Notifications.swift +140 -140
- package/ios/Plugin/Extensions/CapacitorVideoPlayerPlugin.Observers.swift +180 -180
- package/ios/Plugin/Info.plist +24 -24
- package/ios/Plugin/VideoPicker/VideoHelper.swift +127 -127
- package/ios/Plugin/VideoPicker/VideoPickerViewController.swift +144 -144
- package/ios/Plugin/VideoPlayer/Extensions/AVURLAsset.swift +18 -18
- package/ios/Plugin/VideoPlayer/Extensions/AllOrientationAVPlayerController.swift +12 -12
- package/ios/Plugin/VideoPlayer/Extensions/CMTime.swift +23 -23
- package/ios/Plugin/VideoPlayer/Extensions/LandscapeAVPlayerController.swift +12 -12
- package/ios/Plugin/VideoPlayer/Extensions/Notification.Name.swift +18 -18
- package/ios/Plugin/VideoPlayer/Extensions/PortraitAVPlayerController.swift +12 -12
- package/ios/Plugin/VideoPlayer/Extensions/View.swift +54 -54
- package/ios/Plugin/VideoPlayer/FullScreenVideoPlayerView.swift +601 -601
- package/ios/Plugin/VideoPlayer/Models/Video.swift +28 -28
- package/ios/Plugin/VideoPlayer/Models/VideoModel.swift +42 -42
- package/package.json +92 -92
- package/readme.md +196 -190
package/ios/Plugin/Info.plist
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
-
<plist version="1.0">
|
|
4
|
-
<dict>
|
|
5
|
-
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
-
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
7
|
-
<key>CFBundleExecutable</key>
|
|
8
|
-
<string>$(EXECUTABLE_NAME)</string>
|
|
9
|
-
<key>CFBundleIdentifier</key>
|
|
10
|
-
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
11
|
-
<key>CFBundleInfoDictionaryVersion</key>
|
|
12
|
-
<string>6.0</string>
|
|
13
|
-
<key>CFBundleName</key>
|
|
14
|
-
<string>$(PRODUCT_NAME)</string>
|
|
15
|
-
<key>CFBundlePackageType</key>
|
|
16
|
-
<string>FMWK</string>
|
|
17
|
-
<key>CFBundleShortVersionString</key>
|
|
18
|
-
<string>1.0</string>
|
|
19
|
-
<key>CFBundleVersion</key>
|
|
20
|
-
<string>$(CURRENT_PROJECT_VERSION)</string>
|
|
21
|
-
<key>NSPrincipalClass</key>
|
|
22
|
-
<string></string>
|
|
23
|
-
</dict>
|
|
24
|
-
</plist>
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
+
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
7
|
+
<key>CFBundleExecutable</key>
|
|
8
|
+
<string>$(EXECUTABLE_NAME)</string>
|
|
9
|
+
<key>CFBundleIdentifier</key>
|
|
10
|
+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
11
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
|
12
|
+
<string>6.0</string>
|
|
13
|
+
<key>CFBundleName</key>
|
|
14
|
+
<string>$(PRODUCT_NAME)</string>
|
|
15
|
+
<key>CFBundlePackageType</key>
|
|
16
|
+
<string>FMWK</string>
|
|
17
|
+
<key>CFBundleShortVersionString</key>
|
|
18
|
+
<string>1.0</string>
|
|
19
|
+
<key>CFBundleVersion</key>
|
|
20
|
+
<string>$(CURRENT_PROJECT_VERSION)</string>
|
|
21
|
+
<key>NSPrincipalClass</key>
|
|
22
|
+
<string></string>
|
|
23
|
+
</dict>
|
|
24
|
+
</plist>
|
|
@@ -1,127 +1,127 @@
|
|
|
1
|
-
//
|
|
2
|
-
// VideoHelper.swift
|
|
3
|
-
// Plugin
|
|
4
|
-
//
|
|
5
|
-
// Created by Quéau Jean Pierre on 28/05/2021.
|
|
6
|
-
// Copyright © 2021 Max Lynch. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
// Copyright (c) 2021 Razeware LLC
|
|
9
|
-
//
|
|
10
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
12
|
-
// in the Software without restriction, including without limitation the rights
|
|
13
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
15
|
-
// furnished to do so, subject to the following conditions:
|
|
16
|
-
//
|
|
17
|
-
// The above copyright notice and this permission notice shall be included in
|
|
18
|
-
// all copies or substantial portions of the Software.
|
|
19
|
-
//
|
|
20
|
-
// Notwithstanding the foregoing, you may not use, copy, modify, merge, publish,
|
|
21
|
-
// distribute, sublicense, create a derivative work, and/or sell copies of the
|
|
22
|
-
// Software in any work that is designed, intended, or marketed for pedagogical or
|
|
23
|
-
// instructional purposes related to programming, coding, application development,
|
|
24
|
-
// or information technology. Permission for such use, copying, modification,
|
|
25
|
-
// merger, publication, distribution, sublicensing, creation of derivative works,
|
|
26
|
-
// or sale is expressly withheld.
|
|
27
|
-
//
|
|
28
|
-
// This project and source code may use libraries or frameworks that are
|
|
29
|
-
// released under various Open-Source licenses. Use of those libraries and
|
|
30
|
-
// frameworks are governed by their own individual licenses.
|
|
31
|
-
//
|
|
32
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
33
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
34
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
35
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
36
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
37
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
38
|
-
// THE SOFTWARE.
|
|
39
|
-
|
|
40
|
-
import AVFoundation
|
|
41
|
-
import MobileCoreServices
|
|
42
|
-
import UIKit
|
|
43
|
-
|
|
44
|
-
enum VideoHelper {
|
|
45
|
-
static func orientationFromTransform(
|
|
46
|
-
_ transform: CGAffineTransform
|
|
47
|
-
) -> (orientation: UIImage.Orientation, isPortrait: Bool) {
|
|
48
|
-
var assetOrientation = UIImage.Orientation.up
|
|
49
|
-
var isPortrait = false
|
|
50
|
-
let tfA = transform.a
|
|
51
|
-
let tfB = transform.b
|
|
52
|
-
let tfC = transform.c
|
|
53
|
-
let tfD = transform.d
|
|
54
|
-
|
|
55
|
-
if tfA == 0 && tfB == 1.0 && tfC == -1.0 && tfD == 0 {
|
|
56
|
-
assetOrientation = .right
|
|
57
|
-
isPortrait = true
|
|
58
|
-
} else if tfA == 0 && tfB == -1.0 && tfC == 1.0 && tfD == 0 {
|
|
59
|
-
assetOrientation = .left
|
|
60
|
-
isPortrait = true
|
|
61
|
-
} else if tfA == 1.0 && tfB == 0 && tfC == 0 && tfD == 1.0 {
|
|
62
|
-
assetOrientation = .up
|
|
63
|
-
} else if tfA == -1.0 && tfB == 0 && tfC == 0 && tfD == -1.0 {
|
|
64
|
-
assetOrientation = .down
|
|
65
|
-
}
|
|
66
|
-
return (assetOrientation, isPortrait)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
static func startMediaBrowser(
|
|
70
|
-
delegate: UIViewController & UINavigationControllerDelegate & UIImagePickerControllerDelegate,
|
|
71
|
-
sourceType: UIImagePickerController.SourceType
|
|
72
|
-
) {
|
|
73
|
-
guard UIImagePickerController.isSourceTypeAvailable(sourceType)
|
|
74
|
-
else { return }
|
|
75
|
-
|
|
76
|
-
let mediaUI = UIImagePickerController()
|
|
77
|
-
mediaUI.sourceType = sourceType
|
|
78
|
-
mediaUI.mediaTypes = [kUTTypeMovie as String]
|
|
79
|
-
mediaUI.allowsEditing = false
|
|
80
|
-
mediaUI.delegate = delegate
|
|
81
|
-
delegate.present(mediaUI, animated: true, completion: nil)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
static func videoCompositionInstruction(
|
|
85
|
-
_ track: AVCompositionTrack,
|
|
86
|
-
asset: AVAsset
|
|
87
|
-
) -> AVMutableVideoCompositionLayerInstruction {
|
|
88
|
-
let instruction = AVMutableVideoCompositionLayerInstruction(assetTrack: track)
|
|
89
|
-
let assetTrack = asset.tracks(withMediaType: AVMediaType.video)[0]
|
|
90
|
-
|
|
91
|
-
let transform = assetTrack.preferredTransform
|
|
92
|
-
let assetInfo = orientationFromTransform(transform)
|
|
93
|
-
|
|
94
|
-
var scaleToFitRatio = UIScreen.main.bounds.width / assetTrack.naturalSize.width
|
|
95
|
-
if assetInfo.isPortrait {
|
|
96
|
-
scaleToFitRatio = UIScreen.main.bounds.width / assetTrack.naturalSize.height
|
|
97
|
-
let scaleFactor = CGAffineTransform(
|
|
98
|
-
scaleX: scaleToFitRatio,
|
|
99
|
-
y: scaleToFitRatio)
|
|
100
|
-
instruction.setTransform(
|
|
101
|
-
assetTrack.preferredTransform.concatenating(scaleFactor),
|
|
102
|
-
at: .zero)
|
|
103
|
-
} else {
|
|
104
|
-
let scaleFactor = CGAffineTransform(
|
|
105
|
-
scaleX: scaleToFitRatio,
|
|
106
|
-
y: scaleToFitRatio)
|
|
107
|
-
var concat = assetTrack.preferredTransform.concatenating(scaleFactor)
|
|
108
|
-
.concatenating(CGAffineTransform(
|
|
109
|
-
translationX: 0,
|
|
110
|
-
y: UIScreen.main.bounds.width / 2))
|
|
111
|
-
if assetInfo.orientation == .down {
|
|
112
|
-
let fixUpsideDown = CGAffineTransform(rotationAngle: CGFloat(Double.pi))
|
|
113
|
-
let windowBounds = UIScreen.main.bounds
|
|
114
|
-
let yFix = assetTrack.naturalSize.height + windowBounds.height
|
|
115
|
-
let centerFix = CGAffineTransform(
|
|
116
|
-
translationX: assetTrack.naturalSize.width,
|
|
117
|
-
y: yFix)
|
|
118
|
-
concat = fixUpsideDown.concatenating(centerFix).concatenating(scaleFactor)
|
|
119
|
-
}
|
|
120
|
-
instruction.setTransform(concat, at: .zero)
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return instruction
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
import Foundation
|
|
1
|
+
//
|
|
2
|
+
// VideoHelper.swift
|
|
3
|
+
// Plugin
|
|
4
|
+
//
|
|
5
|
+
// Created by Quéau Jean Pierre on 28/05/2021.
|
|
6
|
+
// Copyright © 2021 Max Lynch. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
// Copyright (c) 2021 Razeware LLC
|
|
9
|
+
//
|
|
10
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
// in the Software without restriction, including without limitation the rights
|
|
13
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
// furnished to do so, subject to the following conditions:
|
|
16
|
+
//
|
|
17
|
+
// The above copyright notice and this permission notice shall be included in
|
|
18
|
+
// all copies or substantial portions of the Software.
|
|
19
|
+
//
|
|
20
|
+
// Notwithstanding the foregoing, you may not use, copy, modify, merge, publish,
|
|
21
|
+
// distribute, sublicense, create a derivative work, and/or sell copies of the
|
|
22
|
+
// Software in any work that is designed, intended, or marketed for pedagogical or
|
|
23
|
+
// instructional purposes related to programming, coding, application development,
|
|
24
|
+
// or information technology. Permission for such use, copying, modification,
|
|
25
|
+
// merger, publication, distribution, sublicensing, creation of derivative works,
|
|
26
|
+
// or sale is expressly withheld.
|
|
27
|
+
//
|
|
28
|
+
// This project and source code may use libraries or frameworks that are
|
|
29
|
+
// released under various Open-Source licenses. Use of those libraries and
|
|
30
|
+
// frameworks are governed by their own individual licenses.
|
|
31
|
+
//
|
|
32
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
33
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
34
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
35
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
36
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
37
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
38
|
+
// THE SOFTWARE.
|
|
39
|
+
|
|
40
|
+
import AVFoundation
|
|
41
|
+
import MobileCoreServices
|
|
42
|
+
import UIKit
|
|
43
|
+
|
|
44
|
+
enum VideoHelper {
|
|
45
|
+
static func orientationFromTransform(
|
|
46
|
+
_ transform: CGAffineTransform
|
|
47
|
+
) -> (orientation: UIImage.Orientation, isPortrait: Bool) {
|
|
48
|
+
var assetOrientation = UIImage.Orientation.up
|
|
49
|
+
var isPortrait = false
|
|
50
|
+
let tfA = transform.a
|
|
51
|
+
let tfB = transform.b
|
|
52
|
+
let tfC = transform.c
|
|
53
|
+
let tfD = transform.d
|
|
54
|
+
|
|
55
|
+
if tfA == 0 && tfB == 1.0 && tfC == -1.0 && tfD == 0 {
|
|
56
|
+
assetOrientation = .right
|
|
57
|
+
isPortrait = true
|
|
58
|
+
} else if tfA == 0 && tfB == -1.0 && tfC == 1.0 && tfD == 0 {
|
|
59
|
+
assetOrientation = .left
|
|
60
|
+
isPortrait = true
|
|
61
|
+
} else if tfA == 1.0 && tfB == 0 && tfC == 0 && tfD == 1.0 {
|
|
62
|
+
assetOrientation = .up
|
|
63
|
+
} else if tfA == -1.0 && tfB == 0 && tfC == 0 && tfD == -1.0 {
|
|
64
|
+
assetOrientation = .down
|
|
65
|
+
}
|
|
66
|
+
return (assetOrientation, isPortrait)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static func startMediaBrowser(
|
|
70
|
+
delegate: UIViewController & UINavigationControllerDelegate & UIImagePickerControllerDelegate,
|
|
71
|
+
sourceType: UIImagePickerController.SourceType
|
|
72
|
+
) {
|
|
73
|
+
guard UIImagePickerController.isSourceTypeAvailable(sourceType)
|
|
74
|
+
else { return }
|
|
75
|
+
|
|
76
|
+
let mediaUI = UIImagePickerController()
|
|
77
|
+
mediaUI.sourceType = sourceType
|
|
78
|
+
mediaUI.mediaTypes = [kUTTypeMovie as String]
|
|
79
|
+
mediaUI.allowsEditing = false
|
|
80
|
+
mediaUI.delegate = delegate
|
|
81
|
+
delegate.present(mediaUI, animated: true, completion: nil)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
static func videoCompositionInstruction(
|
|
85
|
+
_ track: AVCompositionTrack,
|
|
86
|
+
asset: AVAsset
|
|
87
|
+
) -> AVMutableVideoCompositionLayerInstruction {
|
|
88
|
+
let instruction = AVMutableVideoCompositionLayerInstruction(assetTrack: track)
|
|
89
|
+
let assetTrack = asset.tracks(withMediaType: AVMediaType.video)[0]
|
|
90
|
+
|
|
91
|
+
let transform = assetTrack.preferredTransform
|
|
92
|
+
let assetInfo = orientationFromTransform(transform)
|
|
93
|
+
|
|
94
|
+
var scaleToFitRatio = UIScreen.main.bounds.width / assetTrack.naturalSize.width
|
|
95
|
+
if assetInfo.isPortrait {
|
|
96
|
+
scaleToFitRatio = UIScreen.main.bounds.width / assetTrack.naturalSize.height
|
|
97
|
+
let scaleFactor = CGAffineTransform(
|
|
98
|
+
scaleX: scaleToFitRatio,
|
|
99
|
+
y: scaleToFitRatio)
|
|
100
|
+
instruction.setTransform(
|
|
101
|
+
assetTrack.preferredTransform.concatenating(scaleFactor),
|
|
102
|
+
at: .zero)
|
|
103
|
+
} else {
|
|
104
|
+
let scaleFactor = CGAffineTransform(
|
|
105
|
+
scaleX: scaleToFitRatio,
|
|
106
|
+
y: scaleToFitRatio)
|
|
107
|
+
var concat = assetTrack.preferredTransform.concatenating(scaleFactor)
|
|
108
|
+
.concatenating(CGAffineTransform(
|
|
109
|
+
translationX: 0,
|
|
110
|
+
y: UIScreen.main.bounds.width / 2))
|
|
111
|
+
if assetInfo.orientation == .down {
|
|
112
|
+
let fixUpsideDown = CGAffineTransform(rotationAngle: CGFloat(Double.pi))
|
|
113
|
+
let windowBounds = UIScreen.main.bounds
|
|
114
|
+
let yFix = assetTrack.naturalSize.height + windowBounds.height
|
|
115
|
+
let centerFix = CGAffineTransform(
|
|
116
|
+
translationX: assetTrack.naturalSize.width,
|
|
117
|
+
y: yFix)
|
|
118
|
+
concat = fixUpsideDown.concatenating(centerFix).concatenating(scaleFactor)
|
|
119
|
+
}
|
|
120
|
+
instruction.setTransform(concat, at: .zero)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return instruction
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
import Foundation
|
|
@@ -1,144 +1,144 @@
|
|
|
1
|
-
//
|
|
2
|
-
// VideoPickerViewController.swift
|
|
3
|
-
// Plugin
|
|
4
|
-
//
|
|
5
|
-
// Created by Quéau Jean Pierre on 11/08/2020.
|
|
6
|
-
// Copyright © 2021 Max Lynch. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
import AVKit
|
|
10
|
-
import MobileCoreServices
|
|
11
|
-
import UIKit
|
|
12
|
-
|
|
13
|
-
open class VideoPickerViewController: UIViewController {
|
|
14
|
-
private var _videoRate: Float = 1.0
|
|
15
|
-
private var _exitOnEnd: Bool = true
|
|
16
|
-
private var _loopOnEnd: Bool = false
|
|
17
|
-
private var _pipEnabled: Bool = true
|
|
18
|
-
private var _backModeEnabled: Bool = true
|
|
19
|
-
private var _showControls: Bool = true
|
|
20
|
-
private var _displayMode: String = "all"
|
|
21
|
-
|
|
22
|
-
// MARK: - Set-up rate
|
|
23
|
-
|
|
24
|
-
var rate: Float {
|
|
25
|
-
get {
|
|
26
|
-
return self._videoRate
|
|
27
|
-
}
|
|
28
|
-
set {
|
|
29
|
-
self._videoRate = newValue
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// MARK: - Set-up exitOnEnd
|
|
34
|
-
|
|
35
|
-
var exitOnEnd: Bool {
|
|
36
|
-
get {
|
|
37
|
-
return self._exitOnEnd
|
|
38
|
-
}
|
|
39
|
-
set {
|
|
40
|
-
self._exitOnEnd = newValue
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// MARK: - Set-up loopOnEnd
|
|
45
|
-
|
|
46
|
-
var loopOnEnd: Bool {
|
|
47
|
-
get {
|
|
48
|
-
return self._loopOnEnd
|
|
49
|
-
}
|
|
50
|
-
set {
|
|
51
|
-
self._loopOnEnd = newValue
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// MARK: - Set-up pipEnabled
|
|
56
|
-
|
|
57
|
-
var pipEnabled: Bool {
|
|
58
|
-
get {
|
|
59
|
-
return self._pipEnabled
|
|
60
|
-
}
|
|
61
|
-
set {
|
|
62
|
-
self._pipEnabled = newValue
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// MARK: - Set-up backModeEnabled
|
|
67
|
-
|
|
68
|
-
var backModeEnabled: Bool {
|
|
69
|
-
get {
|
|
70
|
-
return self._backModeEnabled
|
|
71
|
-
}
|
|
72
|
-
set {
|
|
73
|
-
self._backModeEnabled = newValue
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
// MARK: - Set-up showControls
|
|
77
|
-
|
|
78
|
-
var showControls: Bool {
|
|
79
|
-
get {
|
|
80
|
-
return self._showControls
|
|
81
|
-
}
|
|
82
|
-
set {
|
|
83
|
-
self._showControls = newValue
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// MARK: - Set-up displayMode
|
|
88
|
-
|
|
89
|
-
var displayMode: String {
|
|
90
|
-
get {
|
|
91
|
-
return self._displayMode
|
|
92
|
-
}
|
|
93
|
-
set {
|
|
94
|
-
self._displayMode = newValue
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
override open func viewDidLoad() {
|
|
99
|
-
super.viewDidLoad()
|
|
100
|
-
VideoHelper.startMediaBrowser(delegate: self,
|
|
101
|
-
sourceType: .savedPhotosAlbum)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// MARK: - UIImagePickerControllerDelegate
|
|
107
|
-
extension VideoPickerViewController: UIImagePickerControllerDelegate {
|
|
108
|
-
public func imagePickerController(
|
|
109
|
-
_ picker: UIImagePickerController,
|
|
110
|
-
didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]
|
|
111
|
-
) {
|
|
112
|
-
guard
|
|
113
|
-
let mediaType = info[UIImagePickerController.InfoKey.mediaType] as? String,
|
|
114
|
-
mediaType == (kUTTypeMovie as String),
|
|
115
|
-
let url = info[UIImagePickerController.InfoKey.mediaURL] as? URL
|
|
116
|
-
else {
|
|
117
|
-
return
|
|
118
|
-
}
|
|
119
|
-
let vId: [String: Any] = [
|
|
120
|
-
"videoUrl": url, "videoRate": rate,
|
|
121
|
-
"exitOnEnd": exitOnEnd, "loopOnEnd": loopOnEnd,
|
|
122
|
-
"pipEnabled": pipEnabled,
|
|
123
|
-
"backModeEnabled": backModeEnabled,
|
|
124
|
-
"showControls": showControls,
|
|
125
|
-
"displayMode": displayMode]
|
|
126
|
-
NotificationCenter.default.post(name: .videoPathInternalReady, object: nil, userInfo: vId)
|
|
127
|
-
}
|
|
128
|
-
public func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
|
|
129
|
-
let vId: [String: Any] = [
|
|
130
|
-
"videoUrl": "", "videoRate": rate,
|
|
131
|
-
"exitOnEnd": exitOnEnd, "loopOnEnd": loopOnEnd,
|
|
132
|
-
"pipEnabled": pipEnabled,
|
|
133
|
-
"backModeEnabled": backModeEnabled,
|
|
134
|
-
"showControls": showControls,
|
|
135
|
-
"displayMode": displayMode
|
|
136
|
-
]
|
|
137
|
-
NotificationCenter.default.post(name: .videoPathInternalReady,
|
|
138
|
-
object: nil, userInfo: vId)
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// MARK: - UINavigationControllerDelegate
|
|
143
|
-
extension VideoPickerViewController: UINavigationControllerDelegate {
|
|
144
|
-
}
|
|
1
|
+
//
|
|
2
|
+
// VideoPickerViewController.swift
|
|
3
|
+
// Plugin
|
|
4
|
+
//
|
|
5
|
+
// Created by Quéau Jean Pierre on 11/08/2020.
|
|
6
|
+
// Copyright © 2021 Max Lynch. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
import AVKit
|
|
10
|
+
import MobileCoreServices
|
|
11
|
+
import UIKit
|
|
12
|
+
|
|
13
|
+
open class VideoPickerViewController: UIViewController {
|
|
14
|
+
private var _videoRate: Float = 1.0
|
|
15
|
+
private var _exitOnEnd: Bool = true
|
|
16
|
+
private var _loopOnEnd: Bool = false
|
|
17
|
+
private var _pipEnabled: Bool = true
|
|
18
|
+
private var _backModeEnabled: Bool = true
|
|
19
|
+
private var _showControls: Bool = true
|
|
20
|
+
private var _displayMode: String = "all"
|
|
21
|
+
|
|
22
|
+
// MARK: - Set-up rate
|
|
23
|
+
|
|
24
|
+
var rate: Float {
|
|
25
|
+
get {
|
|
26
|
+
return self._videoRate
|
|
27
|
+
}
|
|
28
|
+
set {
|
|
29
|
+
self._videoRate = newValue
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// MARK: - Set-up exitOnEnd
|
|
34
|
+
|
|
35
|
+
var exitOnEnd: Bool {
|
|
36
|
+
get {
|
|
37
|
+
return self._exitOnEnd
|
|
38
|
+
}
|
|
39
|
+
set {
|
|
40
|
+
self._exitOnEnd = newValue
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// MARK: - Set-up loopOnEnd
|
|
45
|
+
|
|
46
|
+
var loopOnEnd: Bool {
|
|
47
|
+
get {
|
|
48
|
+
return self._loopOnEnd
|
|
49
|
+
}
|
|
50
|
+
set {
|
|
51
|
+
self._loopOnEnd = newValue
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// MARK: - Set-up pipEnabled
|
|
56
|
+
|
|
57
|
+
var pipEnabled: Bool {
|
|
58
|
+
get {
|
|
59
|
+
return self._pipEnabled
|
|
60
|
+
}
|
|
61
|
+
set {
|
|
62
|
+
self._pipEnabled = newValue
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// MARK: - Set-up backModeEnabled
|
|
67
|
+
|
|
68
|
+
var backModeEnabled: Bool {
|
|
69
|
+
get {
|
|
70
|
+
return self._backModeEnabled
|
|
71
|
+
}
|
|
72
|
+
set {
|
|
73
|
+
self._backModeEnabled = newValue
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// MARK: - Set-up showControls
|
|
77
|
+
|
|
78
|
+
var showControls: Bool {
|
|
79
|
+
get {
|
|
80
|
+
return self._showControls
|
|
81
|
+
}
|
|
82
|
+
set {
|
|
83
|
+
self._showControls = newValue
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// MARK: - Set-up displayMode
|
|
88
|
+
|
|
89
|
+
var displayMode: String {
|
|
90
|
+
get {
|
|
91
|
+
return self._displayMode
|
|
92
|
+
}
|
|
93
|
+
set {
|
|
94
|
+
self._displayMode = newValue
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
override open func viewDidLoad() {
|
|
99
|
+
super.viewDidLoad()
|
|
100
|
+
VideoHelper.startMediaBrowser(delegate: self,
|
|
101
|
+
sourceType: .savedPhotosAlbum)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// MARK: - UIImagePickerControllerDelegate
|
|
107
|
+
extension VideoPickerViewController: UIImagePickerControllerDelegate {
|
|
108
|
+
public func imagePickerController(
|
|
109
|
+
_ picker: UIImagePickerController,
|
|
110
|
+
didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]
|
|
111
|
+
) {
|
|
112
|
+
guard
|
|
113
|
+
let mediaType = info[UIImagePickerController.InfoKey.mediaType] as? String,
|
|
114
|
+
mediaType == (kUTTypeMovie as String),
|
|
115
|
+
let url = info[UIImagePickerController.InfoKey.mediaURL] as? URL
|
|
116
|
+
else {
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
let vId: [String: Any] = [
|
|
120
|
+
"videoUrl": url, "videoRate": rate,
|
|
121
|
+
"exitOnEnd": exitOnEnd, "loopOnEnd": loopOnEnd,
|
|
122
|
+
"pipEnabled": pipEnabled,
|
|
123
|
+
"backModeEnabled": backModeEnabled,
|
|
124
|
+
"showControls": showControls,
|
|
125
|
+
"displayMode": displayMode]
|
|
126
|
+
NotificationCenter.default.post(name: .videoPathInternalReady, object: nil, userInfo: vId)
|
|
127
|
+
}
|
|
128
|
+
public func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
|
|
129
|
+
let vId: [String: Any] = [
|
|
130
|
+
"videoUrl": "", "videoRate": rate,
|
|
131
|
+
"exitOnEnd": exitOnEnd, "loopOnEnd": loopOnEnd,
|
|
132
|
+
"pipEnabled": pipEnabled,
|
|
133
|
+
"backModeEnabled": backModeEnabled,
|
|
134
|
+
"showControls": showControls,
|
|
135
|
+
"displayMode": displayMode
|
|
136
|
+
]
|
|
137
|
+
NotificationCenter.default.post(name: .videoPathInternalReady,
|
|
138
|
+
object: nil, userInfo: vId)
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// MARK: - UINavigationControllerDelegate
|
|
143
|
+
extension VideoPickerViewController: UINavigationControllerDelegate {
|
|
144
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
//
|
|
2
|
-
// AVURLAsset.swift
|
|
3
|
-
// Plugin
|
|
4
|
-
//
|
|
5
|
-
// Created by Quéau Jean Pierre on 02/04/2021.
|
|
6
|
-
// Copyright © 2021 Max Lynch. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
import AVKit
|
|
10
|
-
|
|
11
|
-
extension AVURLAsset {
|
|
12
|
-
|
|
13
|
-
var videoSize: CGSize? {
|
|
14
|
-
tracks(withMediaType: .video).first.flatMap {
|
|
15
|
-
tracks.count > 0 ? $0.naturalSize.applying($0.preferredTransform) : nil
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
1
|
+
//
|
|
2
|
+
// AVURLAsset.swift
|
|
3
|
+
// Plugin
|
|
4
|
+
//
|
|
5
|
+
// Created by Quéau Jean Pierre on 02/04/2021.
|
|
6
|
+
// Copyright © 2021 Max Lynch. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
import AVKit
|
|
10
|
+
|
|
11
|
+
extension AVURLAsset {
|
|
12
|
+
|
|
13
|
+
var videoSize: CGSize? {
|
|
14
|
+
tracks(withMediaType: .video).first.flatMap {
|
|
15
|
+
tracks.count > 0 ? $0.naturalSize.applying($0.preferredTransform) : nil
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
//
|
|
2
|
-
// AllOrientationAVPlayerController.swift
|
|
3
|
-
// CapacitorVideoPlayer
|
|
4
|
-
//
|
|
5
|
-
// Created by Manuel Garcia Marin on 24-05-23.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
import AVKit
|
|
9
|
-
class AllOrientationAVPlayerController: AVPlayerViewController {
|
|
10
|
-
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
|
|
11
|
-
return .all }
|
|
12
|
-
}
|
|
1
|
+
//
|
|
2
|
+
// AllOrientationAVPlayerController.swift
|
|
3
|
+
// CapacitorVideoPlayer
|
|
4
|
+
//
|
|
5
|
+
// Created by Manuel Garcia Marin on 24-05-23.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import AVKit
|
|
9
|
+
class AllOrientationAVPlayerController: AVPlayerViewController {
|
|
10
|
+
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
|
|
11
|
+
return .all }
|
|
12
|
+
}
|