@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
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
//
|
|
2
|
-
// CapacitorVideoPlayerPlugin.AVPlayerViewController.swift
|
|
3
|
-
// CapacitorVideoPlayer
|
|
4
|
-
//
|
|
5
|
-
// Created by Quéau Jean Pierre on 10/12/2021.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
import AVFoundation
|
|
9
|
-
import AVKit
|
|
10
|
-
|
|
11
|
-
var isInPIPMode: Bool = false
|
|
12
|
-
var isInBackgroundMode: Bool = false
|
|
13
|
-
var isPIPModeAvailable: Bool = false
|
|
14
|
-
var isVideoEnded: Bool = false
|
|
15
|
-
var isRateZero: Bool = false
|
|
16
|
-
var isPlayerViewRestored: Bool = false
|
|
17
|
-
|
|
18
|
-
extension CapacitorVideoPlayerPlugin: AVPlayerViewControllerDelegate {
|
|
19
|
-
|
|
20
|
-
public func playerViewControllerShouldAutomaticallyDismissAtPictureInPictureStart(_ playerViewController: AVPlayerViewController) -> Bool {
|
|
21
|
-
if isPIPModeAvailable {
|
|
22
|
-
|
|
23
|
-
isInPIPMode = true
|
|
24
|
-
self.bridge?.viewController?.dismiss(animated: true, completion: nil)
|
|
25
|
-
|
|
26
|
-
return true
|
|
27
|
-
} else {
|
|
28
|
-
return false
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
public func playerViewControllerWillStopPictureInPicture(_ playerViewController: AVPlayerViewController) {
|
|
32
|
-
isRateZero = false
|
|
33
|
-
}
|
|
34
|
-
public func playerViewControllerDidStopPictureInPicture(_ playerViewController: AVPlayerViewController) {
|
|
35
|
-
// if !isPlayerViewRestored then the user closed the PIP
|
|
36
|
-
if isPIPModeAvailable && ((isRateZero || isVideoEnded) || !isPlayerViewRestored) {
|
|
37
|
-
isInPIPMode = false
|
|
38
|
-
NotificationCenter.default.post(name: .playerFullscreenDismiss, object: nil)
|
|
39
|
-
}
|
|
40
|
-
isPlayerViewRestored = false
|
|
41
|
-
}
|
|
42
|
-
public func playerViewController(_ playerViewController: AVPlayerViewController, restoreUserInterfaceForPictureInPictureStopWithCompletionHandler completionHandler: @escaping (Bool) -> Void) {
|
|
43
|
-
if isPIPModeAvailable {
|
|
44
|
-
if isInPIPMode && !isVideoEnded {
|
|
45
|
-
isPlayerViewRestored = true
|
|
46
|
-
self.bridge?.viewController?.present(playerViewController, animated: true, completion: nil)
|
|
47
|
-
}
|
|
48
|
-
isInPIPMode = false
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
/* public func playerViewController(_ playerViewController: AVPlayerViewController, willEndFullScreenPresentationWithAnimationCoordinator coordinator: UIViewControllerTransitionCoordinator) {
|
|
53
|
-
if playerViewController.isBeingDismissed {
|
|
54
|
-
playerViewController.dismiss(animated: false) {
|
|
55
|
-
print(">>>>> playerViewController has been dismiss ")
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
*/}
|
|
1
|
+
//
|
|
2
|
+
// CapacitorVideoPlayerPlugin.AVPlayerViewController.swift
|
|
3
|
+
// CapacitorVideoPlayer
|
|
4
|
+
//
|
|
5
|
+
// Created by Quéau Jean Pierre on 10/12/2021.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import AVFoundation
|
|
9
|
+
import AVKit
|
|
10
|
+
|
|
11
|
+
var isInPIPMode: Bool = false
|
|
12
|
+
var isInBackgroundMode: Bool = false
|
|
13
|
+
var isPIPModeAvailable: Bool = false
|
|
14
|
+
var isVideoEnded: Bool = false
|
|
15
|
+
var isRateZero: Bool = false
|
|
16
|
+
var isPlayerViewRestored: Bool = false
|
|
17
|
+
|
|
18
|
+
extension CapacitorVideoPlayerPlugin: AVPlayerViewControllerDelegate {
|
|
19
|
+
|
|
20
|
+
public func playerViewControllerShouldAutomaticallyDismissAtPictureInPictureStart(_ playerViewController: AVPlayerViewController) -> Bool {
|
|
21
|
+
if isPIPModeAvailable {
|
|
22
|
+
|
|
23
|
+
isInPIPMode = true
|
|
24
|
+
self.bridge?.viewController?.dismiss(animated: true, completion: nil)
|
|
25
|
+
|
|
26
|
+
return true
|
|
27
|
+
} else {
|
|
28
|
+
return false
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
public func playerViewControllerWillStopPictureInPicture(_ playerViewController: AVPlayerViewController) {
|
|
32
|
+
isRateZero = false
|
|
33
|
+
}
|
|
34
|
+
public func playerViewControllerDidStopPictureInPicture(_ playerViewController: AVPlayerViewController) {
|
|
35
|
+
// if !isPlayerViewRestored then the user closed the PIP
|
|
36
|
+
if isPIPModeAvailable && ((isRateZero || isVideoEnded) || !isPlayerViewRestored) {
|
|
37
|
+
isInPIPMode = false
|
|
38
|
+
NotificationCenter.default.post(name: .playerFullscreenDismiss, object: nil)
|
|
39
|
+
}
|
|
40
|
+
isPlayerViewRestored = false
|
|
41
|
+
}
|
|
42
|
+
public func playerViewController(_ playerViewController: AVPlayerViewController, restoreUserInterfaceForPictureInPictureStopWithCompletionHandler completionHandler: @escaping (Bool) -> Void) {
|
|
43
|
+
if isPIPModeAvailable {
|
|
44
|
+
if isInPIPMode && !isVideoEnded {
|
|
45
|
+
isPlayerViewRestored = true
|
|
46
|
+
self.bridge?.viewController?.present(playerViewController, animated: true, completion: nil)
|
|
47
|
+
}
|
|
48
|
+
isInPIPMode = false
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
/* public func playerViewController(_ playerViewController: AVPlayerViewController, willEndFullScreenPresentationWithAnimationCoordinator coordinator: UIViewControllerTransitionCoordinator) {
|
|
53
|
+
if playerViewController.isBeingDismissed {
|
|
54
|
+
playerViewController.dismiss(animated: false) {
|
|
55
|
+
print(">>>>> playerViewController has been dismiss ")
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
*/}
|
|
@@ -1,126 +1,126 @@
|
|
|
1
|
-
//
|
|
2
|
-
// CapacitorVideoPlayerPlugin.swift
|
|
3
|
-
// Plugin
|
|
4
|
-
//
|
|
5
|
-
// Created by Quéau Jean Pierre on 30/05/2021.
|
|
6
|
-
// Copyright © 2021 Max Lynch. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
import Foundation
|
|
10
|
-
|
|
11
|
-
extension CapacitorVideoPlayerPlugin {
|
|
12
|
-
|
|
13
|
-
// MARK: - getURLFromFilePath
|
|
14
|
-
|
|
15
|
-
// swiftlint:disable cyclomatic_complexity
|
|
16
|
-
// swiftlint:disable function_body_length
|
|
17
|
-
func getURLFromFilePath(filePath: String) -> [String: Any] {
|
|
18
|
-
var dict: [String: Any] = [:]
|
|
19
|
-
dict["message"] = ""
|
|
20
|
-
let docPath: String =
|
|
21
|
-
NSSearchPathForDirectoriesInDomains(.documentDirectory,
|
|
22
|
-
.userDomainMask,
|
|
23
|
-
true)[0]
|
|
24
|
-
let appPath: String =
|
|
25
|
-
NSSearchPathForDirectoriesInDomains(.applicationDirectory,
|
|
26
|
-
.userDomainMask,
|
|
27
|
-
true)[0]
|
|
28
|
-
|
|
29
|
-
if String(filePath.prefix(4)) == "http" {
|
|
30
|
-
if let url = URL(string: filePath) {
|
|
31
|
-
dict["url"] = url
|
|
32
|
-
return dict
|
|
33
|
-
} else {
|
|
34
|
-
dict["message"] = "cannot convert filePath in URL"
|
|
35
|
-
return dict
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
if String(filePath.prefix(13)) == "public/assets" {
|
|
39
|
-
if let appFolder = Bundle.main.resourceURL {
|
|
40
|
-
dict["url"] = appFolder.appendingPathComponent(filePath)
|
|
41
|
-
return dict
|
|
42
|
-
} else {
|
|
43
|
-
dict["message"] = "did not find appFolder"
|
|
44
|
-
return dict
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if String(filePath.prefix(11)) == "application" {
|
|
48
|
-
let path: String = String(filePath.dropFirst(12))
|
|
49
|
-
let vPath: String = docPath.appendingFormat("/\(path)")
|
|
50
|
-
if !isFileExists(filePath: vPath) {
|
|
51
|
-
print("*** file does not exist at path \n \(vPath) \n***")
|
|
52
|
-
let info: [String: Any] = ["dismiss": true]
|
|
53
|
-
self.notifyListeners("jeepCapVideoPlayerExit", data: info, retainUntilConsumed: true)
|
|
54
|
-
dict["message"] = "file does not exist"
|
|
55
|
-
return dict
|
|
56
|
-
}
|
|
57
|
-
dict["url"] = URL(fileURLWithPath: vPath)
|
|
58
|
-
return dict
|
|
59
|
-
}
|
|
60
|
-
if String(filePath.prefix(29)) == "file:///var/mobile/Containers" {
|
|
61
|
-
|
|
62
|
-
// get the appId from the appPath
|
|
63
|
-
let pathArray = appPath.components(separatedBy: "Application")
|
|
64
|
-
let appId: String = pathArray[1].replacingOccurrences(of: "/", with: "")
|
|
65
|
-
// remove the appId from the given filePath and replace it with the current appId
|
|
66
|
-
let fPathArray = filePath.components(separatedBy: "Application")
|
|
67
|
-
if let uPath = URL(string: pathArray[0]) {
|
|
68
|
-
let fPath = (uPath.appendingPathComponent("Application")
|
|
69
|
-
.appendingPathComponent(appId)
|
|
70
|
-
.appendingPathComponent(
|
|
71
|
-
String(fPathArray[1].dropFirst(38)))
|
|
72
|
-
).absoluteString
|
|
73
|
-
if !isFileExists(filePath: fPath) {
|
|
74
|
-
print("*** file does not exist at path \n \(fPath) \n***")
|
|
75
|
-
let info: [String: Any] = ["dismiss": true]
|
|
76
|
-
self.notifyListeners("jeepCapVideoPlayerExit", data: info,
|
|
77
|
-
retainUntilConsumed: true)
|
|
78
|
-
dict["message"] = "file does not exist"
|
|
79
|
-
return dict
|
|
80
|
-
}
|
|
81
|
-
dict["url"] = URL(fileURLWithPath: fPath)
|
|
82
|
-
} else {
|
|
83
|
-
dict["message"] = "file path not correct"
|
|
84
|
-
}
|
|
85
|
-
return dict
|
|
86
|
-
}
|
|
87
|
-
if String(filePath.prefix(19)) == "file:///var/mobile/" {
|
|
88
|
-
let pathArray = appPath.components(separatedBy: "Containers")
|
|
89
|
-
let fPathArray = filePath.components(separatedBy: "mobile/")
|
|
90
|
-
|
|
91
|
-
if let uPath = URL(string: pathArray[0]) {
|
|
92
|
-
let fPath = (uPath.appendingPathComponent(
|
|
93
|
-
String(fPathArray[1]))
|
|
94
|
-
).absoluteString
|
|
95
|
-
if !isFileExists(filePath: fPath) {
|
|
96
|
-
print("*** file does not exist at path \n \(fPath) \n***")
|
|
97
|
-
let info: [String: Any] = ["dismiss": true]
|
|
98
|
-
self.notifyListeners("jeepCapVideoPlayerExit", data: info,
|
|
99
|
-
retainUntilConsumed: true)
|
|
100
|
-
dict["message"] = "file does not exist"
|
|
101
|
-
return dict
|
|
102
|
-
}
|
|
103
|
-
dict["url"] = URL(fileURLWithPath: fPath)
|
|
104
|
-
} else {
|
|
105
|
-
dict["message"] = "file path not correct"
|
|
106
|
-
}
|
|
107
|
-
return dict
|
|
108
|
-
}
|
|
109
|
-
dict["message"] = "filePath not implemented"
|
|
110
|
-
return dict
|
|
111
|
-
}
|
|
112
|
-
// swiftlint:enable function_body_length
|
|
113
|
-
// swiftlint:enable cyclomatic_complexity
|
|
114
|
-
|
|
115
|
-
// MARK: - isFileExists
|
|
116
|
-
|
|
117
|
-
func isFileExists(filePath: String) -> Bool {
|
|
118
|
-
var ret: Bool = false
|
|
119
|
-
let fileManager = FileManager.default
|
|
120
|
-
if fileManager.fileExists(atPath: filePath) {
|
|
121
|
-
ret = true
|
|
122
|
-
}
|
|
123
|
-
return ret
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
}
|
|
1
|
+
//
|
|
2
|
+
// CapacitorVideoPlayerPlugin.swift
|
|
3
|
+
// Plugin
|
|
4
|
+
//
|
|
5
|
+
// Created by Quéau Jean Pierre on 30/05/2021.
|
|
6
|
+
// Copyright © 2021 Max Lynch. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
import Foundation
|
|
10
|
+
|
|
11
|
+
extension CapacitorVideoPlayerPlugin {
|
|
12
|
+
|
|
13
|
+
// MARK: - getURLFromFilePath
|
|
14
|
+
|
|
15
|
+
// swiftlint:disable cyclomatic_complexity
|
|
16
|
+
// swiftlint:disable function_body_length
|
|
17
|
+
func getURLFromFilePath(filePath: String) -> [String: Any] {
|
|
18
|
+
var dict: [String: Any] = [:]
|
|
19
|
+
dict["message"] = ""
|
|
20
|
+
let docPath: String =
|
|
21
|
+
NSSearchPathForDirectoriesInDomains(.documentDirectory,
|
|
22
|
+
.userDomainMask,
|
|
23
|
+
true)[0]
|
|
24
|
+
let appPath: String =
|
|
25
|
+
NSSearchPathForDirectoriesInDomains(.applicationDirectory,
|
|
26
|
+
.userDomainMask,
|
|
27
|
+
true)[0]
|
|
28
|
+
|
|
29
|
+
if String(filePath.prefix(4)) == "http" {
|
|
30
|
+
if let url = URL(string: filePath) {
|
|
31
|
+
dict["url"] = url
|
|
32
|
+
return dict
|
|
33
|
+
} else {
|
|
34
|
+
dict["message"] = "cannot convert filePath in URL"
|
|
35
|
+
return dict
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if String(filePath.prefix(13)) == "public/assets" {
|
|
39
|
+
if let appFolder = Bundle.main.resourceURL {
|
|
40
|
+
dict["url"] = appFolder.appendingPathComponent(filePath)
|
|
41
|
+
return dict
|
|
42
|
+
} else {
|
|
43
|
+
dict["message"] = "did not find appFolder"
|
|
44
|
+
return dict
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if String(filePath.prefix(11)) == "application" {
|
|
48
|
+
let path: String = String(filePath.dropFirst(12))
|
|
49
|
+
let vPath: String = docPath.appendingFormat("/\(path)")
|
|
50
|
+
if !isFileExists(filePath: vPath) {
|
|
51
|
+
print("*** file does not exist at path \n \(vPath) \n***")
|
|
52
|
+
let info: [String: Any] = ["dismiss": true]
|
|
53
|
+
self.notifyListeners("jeepCapVideoPlayerExit", data: info, retainUntilConsumed: true)
|
|
54
|
+
dict["message"] = "file does not exist"
|
|
55
|
+
return dict
|
|
56
|
+
}
|
|
57
|
+
dict["url"] = URL(fileURLWithPath: vPath)
|
|
58
|
+
return dict
|
|
59
|
+
}
|
|
60
|
+
if String(filePath.prefix(29)) == "file:///var/mobile/Containers" {
|
|
61
|
+
|
|
62
|
+
// get the appId from the appPath
|
|
63
|
+
let pathArray = appPath.components(separatedBy: "Application")
|
|
64
|
+
let appId: String = pathArray[1].replacingOccurrences(of: "/", with: "")
|
|
65
|
+
// remove the appId from the given filePath and replace it with the current appId
|
|
66
|
+
let fPathArray = filePath.components(separatedBy: "Application")
|
|
67
|
+
if let uPath = URL(string: pathArray[0]) {
|
|
68
|
+
let fPath = (uPath.appendingPathComponent("Application")
|
|
69
|
+
.appendingPathComponent(appId)
|
|
70
|
+
.appendingPathComponent(
|
|
71
|
+
String(fPathArray[1].dropFirst(38)))
|
|
72
|
+
).absoluteString
|
|
73
|
+
if !isFileExists(filePath: fPath) {
|
|
74
|
+
print("*** file does not exist at path \n \(fPath) \n***")
|
|
75
|
+
let info: [String: Any] = ["dismiss": true]
|
|
76
|
+
self.notifyListeners("jeepCapVideoPlayerExit", data: info,
|
|
77
|
+
retainUntilConsumed: true)
|
|
78
|
+
dict["message"] = "file does not exist"
|
|
79
|
+
return dict
|
|
80
|
+
}
|
|
81
|
+
dict["url"] = URL(fileURLWithPath: fPath)
|
|
82
|
+
} else {
|
|
83
|
+
dict["message"] = "file path not correct"
|
|
84
|
+
}
|
|
85
|
+
return dict
|
|
86
|
+
}
|
|
87
|
+
if String(filePath.prefix(19)) == "file:///var/mobile/" {
|
|
88
|
+
let pathArray = appPath.components(separatedBy: "Containers")
|
|
89
|
+
let fPathArray = filePath.components(separatedBy: "mobile/")
|
|
90
|
+
|
|
91
|
+
if let uPath = URL(string: pathArray[0]) {
|
|
92
|
+
let fPath = (uPath.appendingPathComponent(
|
|
93
|
+
String(fPathArray[1]))
|
|
94
|
+
).absoluteString
|
|
95
|
+
if !isFileExists(filePath: fPath) {
|
|
96
|
+
print("*** file does not exist at path \n \(fPath) \n***")
|
|
97
|
+
let info: [String: Any] = ["dismiss": true]
|
|
98
|
+
self.notifyListeners("jeepCapVideoPlayerExit", data: info,
|
|
99
|
+
retainUntilConsumed: true)
|
|
100
|
+
dict["message"] = "file does not exist"
|
|
101
|
+
return dict
|
|
102
|
+
}
|
|
103
|
+
dict["url"] = URL(fileURLWithPath: fPath)
|
|
104
|
+
} else {
|
|
105
|
+
dict["message"] = "file path not correct"
|
|
106
|
+
}
|
|
107
|
+
return dict
|
|
108
|
+
}
|
|
109
|
+
dict["message"] = "filePath not implemented"
|
|
110
|
+
return dict
|
|
111
|
+
}
|
|
112
|
+
// swiftlint:enable function_body_length
|
|
113
|
+
// swiftlint:enable cyclomatic_complexity
|
|
114
|
+
|
|
115
|
+
// MARK: - isFileExists
|
|
116
|
+
|
|
117
|
+
func isFileExists(filePath: String) -> Bool {
|
|
118
|
+
var ret: Bool = false
|
|
119
|
+
let fileManager = FileManager.default
|
|
120
|
+
if fileManager.fileExists(atPath: filePath) {
|
|
121
|
+
ret = true
|
|
122
|
+
}
|
|
123
|
+
return ret
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
}
|
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
//
|
|
2
|
-
// CapacitorVideoPlayerPlugin.Fullscreen.swift
|
|
3
|
-
// Plugin
|
|
4
|
-
//
|
|
5
|
-
// Created by Quéau Jean Pierre on 30/05/2021.
|
|
6
|
-
// Copyright © 2021 Max Lynch. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
import Foundation
|
|
10
|
-
import Capacitor
|
|
11
|
-
import AVKit
|
|
12
|
-
|
|
13
|
-
extension CapacitorVideoPlayerPlugin {
|
|
14
|
-
|
|
15
|
-
// MARK: - createVideoPlayerFullScreenView
|
|
16
|
-
|
|
17
|
-
// swiftlint:disable function_body_length
|
|
18
|
-
// swiftlint:disable function_parameter_count
|
|
19
|
-
func createVideoPlayerFullscreenView(
|
|
20
|
-
call: CAPPluginCall, videoUrl: URL, rate: Float,
|
|
21
|
-
exitOnEnd: Bool, loopOnEnd: Bool, pipEnabled: Bool,
|
|
22
|
-
backModeEnabled: Bool, showControls: Bool,
|
|
23
|
-
displayMode: String,
|
|
24
|
-
subTitleUrl: URL?, subTitleLanguage: String?,
|
|
25
|
-
subTitleOptions: [String: Any]?,
|
|
26
|
-
headers: [String: String]?, title: String?,
|
|
27
|
-
smallTitle: String?, artwork: String?) {
|
|
28
|
-
DispatchQueue.main.async { [weak self] in
|
|
29
|
-
let playerId: String = self?.fsPlayerId ?? "fullscreen"
|
|
30
|
-
if let fullscreenView = self?.implementation
|
|
31
|
-
.createFullscreenPlayer(
|
|
32
|
-
playerId: playerId, videoUrl: videoUrl,
|
|
33
|
-
rate: rate, exitOnEnd: exitOnEnd, loopOnEnd: loopOnEnd,
|
|
34
|
-
pipEnabled: pipEnabled,
|
|
35
|
-
showControls: showControls,
|
|
36
|
-
displayMode: displayMode,
|
|
37
|
-
subTitleUrl: subTitleUrl,
|
|
38
|
-
language: subTitleLanguage, headers: headers, options: subTitleOptions,
|
|
39
|
-
title: title, smallTitle: smallTitle, artwork: artwork) {
|
|
40
|
-
self?.videoPlayerFullScreenView = fullscreenView
|
|
41
|
-
if backModeEnabled {
|
|
42
|
-
self?.bgPlayer = self?.videoPlayerFullScreenView?
|
|
43
|
-
.videoPlayer.player
|
|
44
|
-
}
|
|
45
|
-
guard let videoPlayer: AVPlayerViewController =
|
|
46
|
-
self?.videoPlayerFullScreenView?.videoPlayer else {
|
|
47
|
-
let error: String = "No videoPlayer available"
|
|
48
|
-
print(error)
|
|
49
|
-
call.resolve([ "result": false, "method": "createVideoPlayerFullScreenView",
|
|
50
|
-
"message": error])
|
|
51
|
-
return
|
|
52
|
-
}
|
|
53
|
-
videoPlayer.delegate = self
|
|
54
|
-
self?.bridge?.viewController?.present(
|
|
55
|
-
videoPlayer, animated: true, completion: {
|
|
56
|
-
if backModeEnabled {
|
|
57
|
-
// add audio session
|
|
58
|
-
self?.audioSession = AVAudioSession.sharedInstance()
|
|
59
|
-
// Set the audio session category, mode, and options.
|
|
60
|
-
do {
|
|
61
|
-
try self?.audioSession?
|
|
62
|
-
.setCategory(.playback,
|
|
63
|
-
mode: .moviePlayback,
|
|
64
|
-
options: [])
|
|
65
|
-
try self?.audioSession?.setActive(true)
|
|
66
|
-
call.resolve([
|
|
67
|
-
"result": true,
|
|
68
|
-
"method": "createVideoPlayerFullScreenView",
|
|
69
|
-
"value": true])
|
|
70
|
-
return
|
|
71
|
-
} catch let error as NSError {
|
|
72
|
-
print("Unable to activate audio session: \(error.localizedDescription)")
|
|
73
|
-
call.resolve([
|
|
74
|
-
"result": false,
|
|
75
|
-
"method": "createVideoPlayerFullScreenView",
|
|
76
|
-
"message": error.localizedDescription])
|
|
77
|
-
return
|
|
78
|
-
}
|
|
79
|
-
} else {
|
|
80
|
-
call.resolve([
|
|
81
|
-
"result": true,
|
|
82
|
-
"method": "createVideoPlayerFullScreenView",
|
|
83
|
-
"value": true])
|
|
84
|
-
return
|
|
85
|
-
}
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
// swiftlint:enable function_parameter_count
|
|
92
|
-
// swiftlint:enable function_body_length
|
|
93
|
-
|
|
94
|
-
}
|
|
1
|
+
//
|
|
2
|
+
// CapacitorVideoPlayerPlugin.Fullscreen.swift
|
|
3
|
+
// Plugin
|
|
4
|
+
//
|
|
5
|
+
// Created by Quéau Jean Pierre on 30/05/2021.
|
|
6
|
+
// Copyright © 2021 Max Lynch. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
import Foundation
|
|
10
|
+
import Capacitor
|
|
11
|
+
import AVKit
|
|
12
|
+
|
|
13
|
+
extension CapacitorVideoPlayerPlugin {
|
|
14
|
+
|
|
15
|
+
// MARK: - createVideoPlayerFullScreenView
|
|
16
|
+
|
|
17
|
+
// swiftlint:disable function_body_length
|
|
18
|
+
// swiftlint:disable function_parameter_count
|
|
19
|
+
func createVideoPlayerFullscreenView(
|
|
20
|
+
call: CAPPluginCall, videoUrl: URL, rate: Float,
|
|
21
|
+
exitOnEnd: Bool, loopOnEnd: Bool, pipEnabled: Bool,
|
|
22
|
+
backModeEnabled: Bool, showControls: Bool,
|
|
23
|
+
displayMode: String,
|
|
24
|
+
subTitleUrl: URL?, subTitleLanguage: String?,
|
|
25
|
+
subTitleOptions: [String: Any]?,
|
|
26
|
+
headers: [String: String]?, title: String?,
|
|
27
|
+
smallTitle: String?, artwork: String?) {
|
|
28
|
+
DispatchQueue.main.async { [weak self] in
|
|
29
|
+
let playerId: String = self?.fsPlayerId ?? "fullscreen"
|
|
30
|
+
if let fullscreenView = self?.implementation
|
|
31
|
+
.createFullscreenPlayer(
|
|
32
|
+
playerId: playerId, videoUrl: videoUrl,
|
|
33
|
+
rate: rate, exitOnEnd: exitOnEnd, loopOnEnd: loopOnEnd,
|
|
34
|
+
pipEnabled: pipEnabled,
|
|
35
|
+
showControls: showControls,
|
|
36
|
+
displayMode: displayMode,
|
|
37
|
+
subTitleUrl: subTitleUrl,
|
|
38
|
+
language: subTitleLanguage, headers: headers, options: subTitleOptions,
|
|
39
|
+
title: title, smallTitle: smallTitle, artwork: artwork) {
|
|
40
|
+
self?.videoPlayerFullScreenView = fullscreenView
|
|
41
|
+
if backModeEnabled {
|
|
42
|
+
self?.bgPlayer = self?.videoPlayerFullScreenView?
|
|
43
|
+
.videoPlayer.player
|
|
44
|
+
}
|
|
45
|
+
guard let videoPlayer: AVPlayerViewController =
|
|
46
|
+
self?.videoPlayerFullScreenView?.videoPlayer else {
|
|
47
|
+
let error: String = "No videoPlayer available"
|
|
48
|
+
print(error)
|
|
49
|
+
call.resolve([ "result": false, "method": "createVideoPlayerFullScreenView",
|
|
50
|
+
"message": error])
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
videoPlayer.delegate = self
|
|
54
|
+
self?.bridge?.viewController?.present(
|
|
55
|
+
videoPlayer, animated: true, completion: {
|
|
56
|
+
if backModeEnabled {
|
|
57
|
+
// add audio session
|
|
58
|
+
self?.audioSession = AVAudioSession.sharedInstance()
|
|
59
|
+
// Set the audio session category, mode, and options.
|
|
60
|
+
do {
|
|
61
|
+
try self?.audioSession?
|
|
62
|
+
.setCategory(.playback,
|
|
63
|
+
mode: .moviePlayback,
|
|
64
|
+
options: [])
|
|
65
|
+
try self?.audioSession?.setActive(true)
|
|
66
|
+
call.resolve([
|
|
67
|
+
"result": true,
|
|
68
|
+
"method": "createVideoPlayerFullScreenView",
|
|
69
|
+
"value": true])
|
|
70
|
+
return
|
|
71
|
+
} catch let error as NSError {
|
|
72
|
+
print("Unable to activate audio session: \(error.localizedDescription)")
|
|
73
|
+
call.resolve([
|
|
74
|
+
"result": false,
|
|
75
|
+
"method": "createVideoPlayerFullScreenView",
|
|
76
|
+
"message": error.localizedDescription])
|
|
77
|
+
return
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
call.resolve([
|
|
81
|
+
"result": true,
|
|
82
|
+
"method": "createVideoPlayerFullScreenView",
|
|
83
|
+
"value": true])
|
|
84
|
+
return
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// swiftlint:enable function_parameter_count
|
|
92
|
+
// swiftlint:enable function_body_length
|
|
93
|
+
|
|
94
|
+
}
|