@capgo/capacitor-video-player 8.1.7 → 8.1.9

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.
@@ -173,12 +173,12 @@ export interface capVideoPlayerOptions {
173
173
  [key: string]: string;
174
174
  };
175
175
  /**
176
- * Title shown in the player (Android)
176
+ * Title shown in the player and Chromecast metadata (iOS, Android)
177
177
  * by Manuel García Marín (https://github.com/PhantomPainX)
178
178
  */
179
179
  title?: string;
180
180
  /**
181
- * Subtitle shown below the title in the player (Android)
181
+ * Subtitle shown below the title in the player and Chromecast metadata (iOS, Android)
182
182
  * by Manuel García Marín (https://github.com/PhantomPainX)
183
183
  */
184
184
  smallTitle?: string;
@@ -190,13 +190,14 @@ export interface capVideoPlayerOptions {
190
190
  */
191
191
  accentColor?: string;
192
192
  /**
193
- * Chromecast enable/disable (Android)
193
+ * Chromecast enable/disable (iOS, Android)
194
+ * iOS requires Google Cast SDK setup and local network Info.plist keys.
194
195
  * by Manuel García Marín (https://github.com/PhantomPainX)
195
196
  * default: true
196
197
  */
197
198
  chromecast?: boolean;
198
199
  /**
199
- * Artwork url to be shown in Chromecast player
200
+ * Artwork url to be shown in Chromecast player (iOS, Android)
200
201
  * by Manuel García Marín (https://github.com/PhantomPainX)
201
202
  * default: ""
202
203
  */
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface VideoPlayerPlugin {\n /**\n * Initialize a video player\n *\n */\n initPlayer(options: capVideoPlayerOptions): Promise<capVideoPlayerResult>;\n /**\n * Return if a given playerId is playing\n *\n */\n isPlaying(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Play the current video from a given playerId\n *\n */\n play(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Pause the current video from a given playerId\n *\n */\n pause(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Get the duration of the current video from a given playerId\n *\n */\n getDuration(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Get the current time of the current video from a given playerId\n *\n */\n getCurrentTime(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Set the current time to seek the current video to from a given playerId\n *\n */\n setCurrentTime(options: capVideoTimeOptions): Promise<capVideoPlayerResult>;\n /**\n * Get the volume of the current video from a given playerId\n *\n */\n getVolume(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Set the volume of the current video to from a given playerId\n *\n */\n setVolume(options: capVideoVolumeOptions): Promise<capVideoPlayerResult>;\n /**\n * Get the muted of the current video from a given playerId\n *\n */\n getMuted(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Set the muted of the current video to from a given playerId\n *\n */\n setMuted(options: capVideoMutedOptions): Promise<capVideoPlayerResult>;\n /**\n * Set the rate of the current video from a given playerId\n *\n */\n setRate(options: capVideoRateOptions): Promise<capVideoPlayerResult>;\n /**\n * Get the rate of the current video from a given playerId\n *\n */\n getRate(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Stop all players playing\n *\n */\n stopAllPlayers(): Promise<capVideoPlayerResult>;\n /**\n * Show controller\n *\n */\n showController(): Promise<capVideoPlayerResult>;\n /**\n * isControllerIsFullyVisible\n *\n */\n isControllerIsFullyVisible(): Promise<capVideoPlayerResult>;\n /**\n * Exit player\n *\n */\n exitPlayer(): Promise<capVideoPlayerResult>;\n}\nexport interface capEchoOptions {\n /**\n * String to be echoed\n */\n\n value?: string;\n}\nexport interface capVideoPlayerOptions {\n /**\n * Player mode\n * - \"fullscreen\"\n * - \"embedded\" (Web only)\n */\n mode?: string;\n /**\n * The url of the video to play\n */\n url?: string;\n /**\n * The url of subtitle associated with the video\n */\n subtitle?: string;\n /**\n * The language of subtitle\n * see https://github.com/libyal/libfwnt/wiki/Language-Code-identifiers\n */\n language?: string;\n /**\n * SubTitle Options\n */\n subtitleOptions?: SubTitleOptions;\n /**\n * Id of DIV Element parent of the player\n */\n playerId?: string;\n /**\n * Initial playing rate\n */\n rate?: number;\n /**\n * Exit on VideoEnd (iOS, Android)\n * default: true\n */\n exitOnEnd?: boolean;\n /**\n * Loop on VideoEnd when exitOnEnd false (iOS, Android)\n * default: false\n */\n loopOnEnd?: boolean;\n /**\n * Picture in Picture Enable (iOS, Android)\n * default: true\n */\n pipEnabled?: boolean;\n /**\n * Background Mode Enable (iOS, Android)\n * default: true\n */\n bkmodeEnabled?: boolean;\n /**\n * Show Controls Enable (iOS, Android)\n * default: true\n */\n showControls?: boolean;\n /**\n * Display Mode [\"all\", \"portrait\", \"landscape\"] (iOS, Android)\n * default: \"all\"\n */\n displayMode?: string;\n /**\n * Component Tag or DOM Element Tag (React app)\n */\n componentTag?: string;\n /**\n * Player Width (mode \"embedded\" only)\n */\n width?: number;\n /**\n * Player height (mode \"embedded\" only)\n */\n height?: number;\n /**\n * Headers for the request (iOS, Android)\n * by Manuel García Marín (https://github.com/PhantomPainX)\n */\n headers?: {\n [key: string]: string;\n };\n /**\n * Title shown in the player (Android)\n * by Manuel García Marín (https://github.com/PhantomPainX)\n */\n title?: string;\n /**\n * Subtitle shown below the title in the player (Android)\n * by Manuel García Marín (https://github.com/PhantomPainX)\n */\n smallTitle?: string;\n /**\n * ExoPlayer Progress Bar and Spinner color (Android)\n * by Manuel García Marín (https://github.com/PhantomPainX)\n * Must be a valid hex color code\n * default: #FFFFFF\n */\n accentColor?: string;\n /**\n * Chromecast enable/disable (Android)\n * by Manuel García Marín (https://github.com/PhantomPainX)\n * default: true\n */\n chromecast?: boolean;\n /**\n * Artwork url to be shown in Chromecast player\n * by Manuel García Marín (https://github.com/PhantomPainX)\n * default: \"\"\n */\n artwork?: string;\n /**\n * DRM configuration for protected content (iOS: FairPlay, Android: Widevine)\n */\n drm?: DrmOptions;\n}\nexport interface capVideoPlayerIdOptions {\n /**\n * Id of DIV Element parent of the player\n */\n playerId?: string;\n}\nexport interface capVideoRateOptions {\n /**\n * Id of DIV Element parent of the player\n */\n playerId?: string;\n /**\n * Rate value\n */\n rate?: number;\n}\nexport interface capVideoVolumeOptions {\n /**\n * Id of DIV Element parent of the player\n */\n playerId?: string;\n /**\n * Volume value between [0 - 1]\n */\n volume?: number;\n}\nexport interface capVideoTimeOptions {\n /**\n * Id of DIV Element parent of the player\n */\n playerId?: string;\n /**\n * Video time value you want to seek to\n */\n seektime?: number;\n}\nexport interface capVideoMutedOptions {\n /**\n * Id of DIV Element parent of the player\n */\n playerId?: string;\n /**\n * Muted value true or false\n */\n muted?: boolean;\n}\nexport interface capVideoListener {\n /**\n * Id of DIV Element parent of the player\n */\n playerId?: string;\n /**\n * Video current time when listener triggered\n */\n currentTime?: number;\n}\nexport interface capExitListener {\n /**\n * Dismiss value true or false\n */\n dismiss?: boolean;\n /**\n * Video current time when listener triggered\n */\n currentTime?: number;\n}\nexport interface capVideoPlayerResult {\n /**\n * result set to true when successful else false\n */\n result?: boolean;\n /**\n * method name\n */\n method?: string;\n /**\n * value returned\n */\n value?: any;\n /**\n * message string\n */\n message?: string;\n}\nexport interface SubTitleOptions {\n /**\n * Foreground Color in RGBA (default rgba(255,255,255,1)\n */\n foregroundColor?: string;\n /**\n * Background Color in RGBA (default rgba(0,0,0,1)\n */\n backgroundColor?: string;\n /**\n * Font Size in pixels (default 16)\n */\n fontSize?: number;\n\n /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ id: string }>} an Promise with version for this device\n * @throws An error if the something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n}\nexport interface FairPlayDrmOptions {\n /**\n * The URL to fetch the FairPlay certificate\n */\n certificateUrl?: string;\n /**\n * The URL to send the SPC and receive the CKC license (FairPlay license server URL)\n */\n contentKeySpcUrl?: string;\n}\nexport interface PlayreadyDrmOptions {\n /**\n * The URL to fetch the PlayReady license\n */\n certificateUrl?: string;\n}\nexport interface WidevineDrmOptions {\n /**\n * The URL to fetch the Widevine license\n */\n certificateUrl?: string;\n}\nexport interface DrmOptions {\n /**\n * FairPlay DRM configuration (iOS)\n */\n fairplay?: FairPlayDrmOptions;\n /**\n * PlayReady DRM configuration\n */\n playready?: PlayreadyDrmOptions;\n /**\n * Widevine DRM configuration (Android)\n */\n widevine?: WidevineDrmOptions;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface VideoPlayerPlugin {\n /**\n * Initialize a video player\n *\n */\n initPlayer(options: capVideoPlayerOptions): Promise<capVideoPlayerResult>;\n /**\n * Return if a given playerId is playing\n *\n */\n isPlaying(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Play the current video from a given playerId\n *\n */\n play(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Pause the current video from a given playerId\n *\n */\n pause(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Get the duration of the current video from a given playerId\n *\n */\n getDuration(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Get the current time of the current video from a given playerId\n *\n */\n getCurrentTime(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Set the current time to seek the current video to from a given playerId\n *\n */\n setCurrentTime(options: capVideoTimeOptions): Promise<capVideoPlayerResult>;\n /**\n * Get the volume of the current video from a given playerId\n *\n */\n getVolume(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Set the volume of the current video to from a given playerId\n *\n */\n setVolume(options: capVideoVolumeOptions): Promise<capVideoPlayerResult>;\n /**\n * Get the muted of the current video from a given playerId\n *\n */\n getMuted(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Set the muted of the current video to from a given playerId\n *\n */\n setMuted(options: capVideoMutedOptions): Promise<capVideoPlayerResult>;\n /**\n * Set the rate of the current video from a given playerId\n *\n */\n setRate(options: capVideoRateOptions): Promise<capVideoPlayerResult>;\n /**\n * Get the rate of the current video from a given playerId\n *\n */\n getRate(options: capVideoPlayerIdOptions): Promise<capVideoPlayerResult>;\n /**\n * Stop all players playing\n *\n */\n stopAllPlayers(): Promise<capVideoPlayerResult>;\n /**\n * Show controller\n *\n */\n showController(): Promise<capVideoPlayerResult>;\n /**\n * isControllerIsFullyVisible\n *\n */\n isControllerIsFullyVisible(): Promise<capVideoPlayerResult>;\n /**\n * Exit player\n *\n */\n exitPlayer(): Promise<capVideoPlayerResult>;\n}\nexport interface capEchoOptions {\n /**\n * String to be echoed\n */\n\n value?: string;\n}\nexport interface capVideoPlayerOptions {\n /**\n * Player mode\n * - \"fullscreen\"\n * - \"embedded\" (Web only)\n */\n mode?: string;\n /**\n * The url of the video to play\n */\n url?: string;\n /**\n * The url of subtitle associated with the video\n */\n subtitle?: string;\n /**\n * The language of subtitle\n * see https://github.com/libyal/libfwnt/wiki/Language-Code-identifiers\n */\n language?: string;\n /**\n * SubTitle Options\n */\n subtitleOptions?: SubTitleOptions;\n /**\n * Id of DIV Element parent of the player\n */\n playerId?: string;\n /**\n * Initial playing rate\n */\n rate?: number;\n /**\n * Exit on VideoEnd (iOS, Android)\n * default: true\n */\n exitOnEnd?: boolean;\n /**\n * Loop on VideoEnd when exitOnEnd false (iOS, Android)\n * default: false\n */\n loopOnEnd?: boolean;\n /**\n * Picture in Picture Enable (iOS, Android)\n * default: true\n */\n pipEnabled?: boolean;\n /**\n * Background Mode Enable (iOS, Android)\n * default: true\n */\n bkmodeEnabled?: boolean;\n /**\n * Show Controls Enable (iOS, Android)\n * default: true\n */\n showControls?: boolean;\n /**\n * Display Mode [\"all\", \"portrait\", \"landscape\"] (iOS, Android)\n * default: \"all\"\n */\n displayMode?: string;\n /**\n * Component Tag or DOM Element Tag (React app)\n */\n componentTag?: string;\n /**\n * Player Width (mode \"embedded\" only)\n */\n width?: number;\n /**\n * Player height (mode \"embedded\" only)\n */\n height?: number;\n /**\n * Headers for the request (iOS, Android)\n * by Manuel García Marín (https://github.com/PhantomPainX)\n */\n headers?: {\n [key: string]: string;\n };\n /**\n * Title shown in the player and Chromecast metadata (iOS, Android)\n * by Manuel García Marín (https://github.com/PhantomPainX)\n */\n title?: string;\n /**\n * Subtitle shown below the title in the player and Chromecast metadata (iOS, Android)\n * by Manuel García Marín (https://github.com/PhantomPainX)\n */\n smallTitle?: string;\n /**\n * ExoPlayer Progress Bar and Spinner color (Android)\n * by Manuel García Marín (https://github.com/PhantomPainX)\n * Must be a valid hex color code\n * default: #FFFFFF\n */\n accentColor?: string;\n /**\n * Chromecast enable/disable (iOS, Android)\n * iOS requires Google Cast SDK setup and local network Info.plist keys.\n * by Manuel García Marín (https://github.com/PhantomPainX)\n * default: true\n */\n chromecast?: boolean;\n /**\n * Artwork url to be shown in Chromecast player (iOS, Android)\n * by Manuel García Marín (https://github.com/PhantomPainX)\n * default: \"\"\n */\n artwork?: string;\n /**\n * DRM configuration for protected content (iOS: FairPlay, Android: Widevine)\n */\n drm?: DrmOptions;\n}\nexport interface capVideoPlayerIdOptions {\n /**\n * Id of DIV Element parent of the player\n */\n playerId?: string;\n}\nexport interface capVideoRateOptions {\n /**\n * Id of DIV Element parent of the player\n */\n playerId?: string;\n /**\n * Rate value\n */\n rate?: number;\n}\nexport interface capVideoVolumeOptions {\n /**\n * Id of DIV Element parent of the player\n */\n playerId?: string;\n /**\n * Volume value between [0 - 1]\n */\n volume?: number;\n}\nexport interface capVideoTimeOptions {\n /**\n * Id of DIV Element parent of the player\n */\n playerId?: string;\n /**\n * Video time value you want to seek to\n */\n seektime?: number;\n}\nexport interface capVideoMutedOptions {\n /**\n * Id of DIV Element parent of the player\n */\n playerId?: string;\n /**\n * Muted value true or false\n */\n muted?: boolean;\n}\nexport interface capVideoListener {\n /**\n * Id of DIV Element parent of the player\n */\n playerId?: string;\n /**\n * Video current time when listener triggered\n */\n currentTime?: number;\n}\nexport interface capExitListener {\n /**\n * Dismiss value true or false\n */\n dismiss?: boolean;\n /**\n * Video current time when listener triggered\n */\n currentTime?: number;\n}\nexport interface capVideoPlayerResult {\n /**\n * result set to true when successful else false\n */\n result?: boolean;\n /**\n * method name\n */\n method?: string;\n /**\n * value returned\n */\n value?: any;\n /**\n * message string\n */\n message?: string;\n}\nexport interface SubTitleOptions {\n /**\n * Foreground Color in RGBA (default rgba(255,255,255,1)\n */\n foregroundColor?: string;\n /**\n * Background Color in RGBA (default rgba(0,0,0,1)\n */\n backgroundColor?: string;\n /**\n * Font Size in pixels (default 16)\n */\n fontSize?: number;\n\n /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ id: string }>} an Promise with version for this device\n * @throws An error if the something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n}\nexport interface FairPlayDrmOptions {\n /**\n * The URL to fetch the FairPlay certificate\n */\n certificateUrl?: string;\n /**\n * The URL to send the SPC and receive the CKC license (FairPlay license server URL)\n */\n contentKeySpcUrl?: string;\n}\nexport interface PlayreadyDrmOptions {\n /**\n * The URL to fetch the PlayReady license\n */\n certificateUrl?: string;\n}\nexport interface WidevineDrmOptions {\n /**\n * The URL to fetch the Widevine license\n */\n certificateUrl?: string;\n}\nexport interface DrmOptions {\n /**\n * FairPlay DRM configuration (iOS)\n */\n fairplay?: FairPlayDrmOptions;\n /**\n * PlayReady DRM configuration\n */\n playready?: PlayreadyDrmOptions;\n /**\n * Widevine DRM configuration (Android)\n */\n widevine?: WidevineDrmOptions;\n}\n"]}
@@ -13,6 +13,10 @@ class FullscreenVideoPlayer: NSObject {
13
13
  private var loopOnEnd: Bool
14
14
  private var pipEnabled: Bool
15
15
  private var showControls: Bool
16
+ private var chromecast: Bool
17
+ private var title: String?
18
+ private var smallTitle: String?
19
+ private var artwork: String?
16
20
  private var rate: Float
17
21
  private var timeObserver: Any?
18
22
  private var onPlay: (() -> Void)?
@@ -23,8 +27,23 @@ class FullscreenVideoPlayer: NSObject {
23
27
  private var fairplayCertificateUrl: String?
24
28
  private var fairplayContentKeySpcUrl: String?
25
29
  private var contentKeySession: AVContentKeySession?
26
-
27
- init(playerId: String, url: String, rate: Float, exitOnEnd: Bool, loopOnEnd: Bool, pipEnabled: Bool, showControls: Bool, fairplayCertificateUrl: String? = nil, fairplayContentKeySpcUrl: String? = nil) {
30
+ private var castController: VideoPlayerCastController?
31
+
32
+ init(
33
+ playerId: String,
34
+ url: String,
35
+ rate: Float,
36
+ exitOnEnd: Bool,
37
+ loopOnEnd: Bool,
38
+ pipEnabled: Bool,
39
+ showControls: Bool,
40
+ chromecast: Bool,
41
+ title: String? = nil,
42
+ smallTitle: String? = nil,
43
+ artwork: String? = nil,
44
+ fairplayCertificateUrl: String? = nil,
45
+ fairplayContentKeySpcUrl: String? = nil
46
+ ) {
28
47
  self.playerId = playerId
29
48
  self.videoUrl = url
30
49
  self.rate = rate
@@ -32,6 +51,10 @@ class FullscreenVideoPlayer: NSObject {
32
51
  self.loopOnEnd = loopOnEnd
33
52
  self.pipEnabled = pipEnabled
34
53
  self.showControls = showControls
54
+ self.chromecast = chromecast
55
+ self.title = title
56
+ self.smallTitle = smallTitle
57
+ self.artwork = artwork
35
58
  self.fairplayCertificateUrl = fairplayCertificateUrl
36
59
  self.fairplayContentKeySpcUrl = fairplayContentKeySpcUrl
37
60
  super.init()
@@ -66,11 +89,37 @@ class FullscreenVideoPlayer: NSObject {
66
89
 
67
90
  // Picture in Picture support
68
91
  playerViewController?.allowsPictureInPicturePlayback = pipEnabled
92
+ setupChromecast()
69
93
 
70
94
  // Setup observers
71
95
  setupObservers()
72
96
  }
73
97
 
98
+ private func setupChromecast() {
99
+ guard chromecast,
100
+ let playerViewController = playerViewController,
101
+ let player = player else {
102
+ return
103
+ }
104
+
105
+ castController = VideoPlayerCastController(
106
+ videoUrl: videoUrl,
107
+ title: title,
108
+ smallTitle: smallTitle,
109
+ artwork: artwork
110
+ )
111
+ castController?.setOnPlay { [weak self] in
112
+ self?.onPlay?()
113
+ }
114
+ castController?.setOnPause { [weak self] in
115
+ self?.onPause?()
116
+ }
117
+ castController?.setOnEnd { [weak self] in
118
+ self?.handlePlaybackEnded()
119
+ }
120
+ castController?.attach(to: playerViewController, player: player)
121
+ }
122
+
74
123
  private func setupObservers() {
75
124
  guard let player = player else { return }
76
125
 
@@ -115,7 +164,14 @@ class FullscreenVideoPlayer: NSObject {
115
164
  }
116
165
 
117
166
  @objc private func playerDidFinishPlaying() {
167
+ handlePlaybackEnded()
168
+ }
169
+
170
+ private func handlePlaybackEnded() {
118
171
  if loopOnEnd {
172
+ if castController?.restartPlayback() == true {
173
+ return
174
+ }
119
175
  player?.seek(to: .zero)
120
176
  player?.play()
121
177
  } else if exitOnEnd {
@@ -133,13 +189,14 @@ class FullscreenVideoPlayer: NSObject {
133
189
  }
134
190
 
135
191
  viewController.present(playerVC, animated: true) {
136
- self.player?.play()
192
+ self.play()
137
193
  completion()
138
194
  }
139
195
  }
140
196
 
141
197
  func dismiss() {
142
198
  let currentTime = getCurrentTime()
199
+ castController?.detach(stopRemoteMedia: true)
143
200
  playerViewController?.dismiss(animated: true) { [weak self] in
144
201
  self?.cleanup()
145
202
  self?.onExit?(currentTime)
@@ -147,6 +204,8 @@ class FullscreenVideoPlayer: NSObject {
147
204
  }
148
205
 
149
206
  private func cleanup() {
207
+ castController?.detach(stopRemoteMedia: false)
208
+ castController = nil
150
209
  if let observer = timeObserver {
151
210
  player?.removeObserver(self, forKeyPath: "rate")
152
211
  player?.removeTimeObserver(observer)
@@ -163,54 +222,91 @@ class FullscreenVideoPlayer: NSObject {
163
222
  // MARK: - Playback Control
164
223
 
165
224
  func play() {
225
+ if castController?.play() == true {
226
+ return
227
+ }
166
228
  player?.play()
167
229
  }
168
230
 
169
231
  func pause() {
232
+ if castController?.pause() == true {
233
+ return
234
+ }
170
235
  player?.pause()
171
236
  }
172
237
 
173
238
  func isPlaying() -> Bool {
239
+ if castController?.isCasting == true {
240
+ return castController?.isPlaying() ?? false
241
+ }
174
242
  guard let player = player else { return false }
175
243
  return player.rate > 0
176
244
  }
177
245
 
178
246
  func getDuration() -> Double {
247
+ if castController?.isCasting == true {
248
+ return castController?.getDuration() ?? 0
249
+ }
179
250
  guard let duration = playerItem?.duration else { return 0 }
180
251
  return CMTimeGetSeconds(duration)
181
252
  }
182
253
 
183
254
  func getCurrentTime() -> Double {
255
+ if castController?.isCasting == true {
256
+ return castController?.getCurrentTime() ?? 0
257
+ }
184
258
  guard let currentTime = player?.currentTime() else { return 0 }
185
259
  return CMTimeGetSeconds(currentTime)
186
260
  }
187
261
 
188
262
  func setCurrentTime(_ time: Double) {
263
+ if castController?.setCurrentTime(time) == true {
264
+ return
265
+ }
189
266
  let cmTime = CMTime(seconds: time, preferredTimescale: 600)
190
267
  player?.seek(to: cmTime)
191
268
  }
192
269
 
193
270
  func getVolume() -> Float {
271
+ if castController?.isCasting == true {
272
+ return castController?.getVolume() ?? 0
273
+ }
194
274
  return player?.volume ?? 0
195
275
  }
196
276
 
197
277
  func setVolume(_ volume: Float) {
278
+ if castController?.setVolume(volume) == true {
279
+ return
280
+ }
198
281
  player?.volume = volume
199
282
  }
200
283
 
201
284
  func getMuted() -> Bool {
285
+ if castController?.isCasting == true {
286
+ return castController?.getMuted() ?? false
287
+ }
202
288
  return player?.isMuted ?? false
203
289
  }
204
290
 
205
291
  func setMuted(_ muted: Bool) {
292
+ if castController?.setMuted(muted) == true {
293
+ return
294
+ }
206
295
  player?.isMuted = muted
207
296
  }
208
297
 
209
298
  func getRate() -> Float {
299
+ if castController?.isCasting == true {
300
+ return castController?.getRate() ?? 0
301
+ }
210
302
  return player?.rate ?? 0
211
303
  }
212
304
 
213
305
  func setRate(_ rate: Float) {
306
+ if castController?.setRate(rate) == true {
307
+ self.rate = rate
308
+ return
309
+ }
214
310
  player?.rate = rate
215
311
  self.rate = rate
216
312
  }
@@ -278,7 +374,7 @@ extension FullscreenVideoPlayer: AVContentKeySessionDelegate {
278
374
  guard let certData = certData else {
279
375
  keyRequest.processContentKeyResponseError(
280
376
  certError ?? NSError(domain: "VideoPlayer", code: -2,
281
- userInfo: [NSLocalizedDescriptionKey: "Failed to fetch FairPlay certificate"])
377
+ userInfo: [NSLocalizedDescriptionKey: "Failed to fetch FairPlay certificate"])
282
378
  )
283
379
  return
284
380
  }