@capgo/capacitor-video-player 8.1.8 → 8.1.10

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.
@@ -13,5 +13,6 @@ Pod::Spec.new do |s|
13
13
  s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
14
14
  s.ios.deployment_target = '15.0'
15
15
  s.dependency 'Capacitor'
16
+ s.dependency 'google-cast-sdk', '~> 4.8.4'
16
17
  s.swift_version = '5.1'
17
18
  end
package/Package.swift CHANGED
@@ -10,14 +10,16 @@ let package = Package(
10
10
  targets: ["VideoPlayerPlugin"])
11
11
  ],
12
12
  dependencies: [
13
- .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0")
13
+ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0"),
14
+ .package(url: "https://github.com/SRGSSR/google-cast-sdk.git", exact: "4.8.4")
14
15
  ],
15
16
  targets: [
16
17
  .target(
17
18
  name: "VideoPlayerPlugin",
18
19
  dependencies: [
19
20
  .product(name: "Capacitor", package: "capacitor-swift-pm"),
20
- .product(name: "Cordova", package: "capacitor-swift-pm")
21
+ .product(name: "Cordova", package: "capacitor-swift-pm"),
22
+ .product(name: "GoogleCast", package: "google-cast-sdk")
21
23
  ],
22
24
  path: "ios/Sources/VideoPlayerPlugin"),
23
25
  .testTarget(
package/README.md CHANGED
@@ -25,8 +25,36 @@ The most complete doc is available here: https://capgo.app/docs/plugins/video-pl
25
25
  ## Install
26
26
 
27
27
  ```bash
28
- npm install @capgo/capacitor-video-player
29
- npx cap sync
28
+ bun add @capgo/capacitor-video-player
29
+ bunx cap sync
30
+ ```
31
+
32
+ ## iOS Chromecast setup
33
+
34
+ iOS Chromecast uses the Google Cast SDK default media receiver. When `chromecast` is enabled, the plugin adds a Cast button over the fullscreen iOS player, loads the current media on the selected receiver, and keeps plugin play/pause/seek/volume calls pointed at the active Cast session.
35
+
36
+ For Cast discovery on iOS, add local network keys to your app `Info.plist`.
37
+
38
+ ```xml
39
+ <key>NSBonjourServices</key>
40
+ <array>
41
+ <string>_googlecast._tcp</string>
42
+ <string>_CC1AD845._googlecast._tcp</string>
43
+ </array>
44
+ <key>NSLocalNetworkUsageDescription</key>
45
+ <string>$(PRODUCT_NAME) uses the local network to discover Cast-enabled devices on your WiFi network.</string>
46
+ ```
47
+
48
+ ```ts
49
+ await VideoPlayer.initPlayer({
50
+ playerId: 'fullscreen',
51
+ mode: 'fullscreen',
52
+ url: 'https://example.com/video.mp4',
53
+ title: 'Video title',
54
+ smallTitle: 'Video subtitle',
55
+ artwork: 'https://example.com/poster.jpg',
56
+ chromecast: true,
57
+ });
30
58
  ```
31
59
 
32
60
  ## Supported Features
@@ -389,31 +417,31 @@ Exit player
389
417
 
390
418
  #### capVideoPlayerOptions
391
419
 
392
- | Prop | Type | Description |
393
- | --------------------- | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
394
- | **`mode`** | <code>string</code> | Player mode - "fullscreen" - "embedded" (Web only) |
395
- | **`url`** | <code>string</code> | The url of the video to play |
396
- | **`subtitle`** | <code>string</code> | The url of subtitle associated with the video |
397
- | **`language`** | <code>string</code> | The language of subtitle see https://github.com/libyal/libfwnt/wiki/Language-Code-identifiers |
398
- | **`subtitleOptions`** | <code><a href="#subtitleoptions">SubTitleOptions</a></code> | SubTitle Options |
399
- | **`playerId`** | <code>string</code> | Id of DIV Element parent of the player |
400
- | **`rate`** | <code>number</code> | Initial playing rate |
401
- | **`exitOnEnd`** | <code>boolean</code> | Exit on VideoEnd (iOS, Android) default: true |
402
- | **`loopOnEnd`** | <code>boolean</code> | Loop on VideoEnd when exitOnEnd false (iOS, Android) default: false |
403
- | **`pipEnabled`** | <code>boolean</code> | Picture in Picture Enable (iOS, Android) default: true |
404
- | **`bkmodeEnabled`** | <code>boolean</code> | Background Mode Enable (iOS, Android) default: true |
405
- | **`showControls`** | <code>boolean</code> | Show Controls Enable (iOS, Android) default: true |
406
- | **`displayMode`** | <code>string</code> | Display Mode ["all", "portrait", "landscape"] (iOS, Android) default: "all" |
407
- | **`componentTag`** | <code>string</code> | Component Tag or DOM Element Tag (React app) |
408
- | **`width`** | <code>number</code> | Player Width (mode "embedded" only) |
409
- | **`height`** | <code>number</code> | Player height (mode "embedded" only) |
410
- | **`headers`** | <code>{ [key: string]: string; }</code> | Headers for the request (iOS, Android) by Manuel García Marín (https://github.com/PhantomPainX) |
411
- | **`title`** | <code>string</code> | Title shown in the player (Android) by Manuel García Marín (https://github.com/PhantomPainX) |
412
- | **`smallTitle`** | <code>string</code> | Subtitle shown below the title in the player (Android) by Manuel García Marín (https://github.com/PhantomPainX) |
413
- | **`accentColor`** | <code>string</code> | ExoPlayer Progress Bar and Spinner color (Android) by Manuel García Marín (https://github.com/PhantomPainX) Must be a valid hex color code default: #FFFFFF |
414
- | **`chromecast`** | <code>boolean</code> | Chromecast enable/disable (Android) by Manuel García Marín (https://github.com/PhantomPainX) default: true |
415
- | **`artwork`** | <code>string</code> | Artwork url to be shown in Chromecast player by Manuel García Marín (https://github.com/PhantomPainX) default: "" |
416
- | **`drm`** | <code><a href="#drmoptions">DrmOptions</a></code> | DRM configuration for protected content (iOS: FairPlay, Android: Widevine) |
420
+ | Prop | Type | Description |
421
+ | --------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
422
+ | **`mode`** | <code>string</code> | Player mode - "fullscreen" - "embedded" (Web only) |
423
+ | **`url`** | <code>string</code> | The url of the video to play |
424
+ | **`subtitle`** | <code>string</code> | The url of subtitle associated with the video |
425
+ | **`language`** | <code>string</code> | The language of subtitle see https://github.com/libyal/libfwnt/wiki/Language-Code-identifiers |
426
+ | **`subtitleOptions`** | <code><a href="#subtitleoptions">SubTitleOptions</a></code> | SubTitle Options |
427
+ | **`playerId`** | <code>string</code> | Id of DIV Element parent of the player |
428
+ | **`rate`** | <code>number</code> | Initial playing rate |
429
+ | **`exitOnEnd`** | <code>boolean</code> | Exit on VideoEnd (iOS, Android) default: true |
430
+ | **`loopOnEnd`** | <code>boolean</code> | Loop on VideoEnd when exitOnEnd false (iOS, Android) default: false |
431
+ | **`pipEnabled`** | <code>boolean</code> | Picture in Picture Enable (iOS, Android) default: true |
432
+ | **`bkmodeEnabled`** | <code>boolean</code> | Background Mode Enable (iOS, Android) default: true |
433
+ | **`showControls`** | <code>boolean</code> | Show Controls Enable (iOS, Android) default: true |
434
+ | **`displayMode`** | <code>string</code> | Display Mode ["all", "portrait", "landscape"] (iOS, Android) default: "all" |
435
+ | **`componentTag`** | <code>string</code> | Component Tag or DOM Element Tag (React app) |
436
+ | **`width`** | <code>number</code> | Player Width (mode "embedded" only) |
437
+ | **`height`** | <code>number</code> | Player height (mode "embedded" only) |
438
+ | **`headers`** | <code>{ [key: string]: string; }</code> | Headers for the request (iOS, Android) by Manuel García Marín (https://github.com/PhantomPainX) |
439
+ | **`title`** | <code>string</code> | Title shown in the player and Chromecast metadata (iOS, Android) by Manuel García Marín (https://github.com/PhantomPainX) |
440
+ | **`smallTitle`** | <code>string</code> | Subtitle shown below the title in the player and Chromecast metadata (iOS, Android) by Manuel García Marín (https://github.com/PhantomPainX) |
441
+ | **`accentColor`** | <code>string</code> | ExoPlayer Progress Bar and Spinner color (Android) by Manuel García Marín (https://github.com/PhantomPainX) Must be a valid hex color code default: #FFFFFF |
442
+ | **`chromecast`** | <code>boolean</code> | Chromecast enable/disable (iOS, Android) iOS requires Google Cast SDK setup and local network Info.plist keys. by Manuel García Marín (https://github.com/PhantomPainX) default: true |
443
+ | **`artwork`** | <code>string</code> | Artwork url to be shown in Chromecast player (iOS, Android) by Manuel García Marín (https://github.com/PhantomPainX) default: "" |
444
+ | **`drm`** | <code><a href="#drmoptions">DrmOptions</a></code> | DRM configuration for protected content (iOS: FairPlay, Android: Widevine) |
417
445
 
418
446
 
419
447
  #### SubTitleOptions
@@ -38,7 +38,7 @@ import java.util.Map;
38
38
  )
39
39
  public class VideoPlayerPlugin extends Plugin {
40
40
 
41
- private final String pluginVersion = "8.1.8";
41
+ private final String pluginVersion = "8.1.10";
42
42
 
43
43
  // Permission alias constants
44
44
  private static final String PERMISSION_DENIED_ERROR = "Unable to access media videos, user denied permission request";
package/dist/docs.json CHANGED
@@ -472,14 +472,14 @@
472
472
  {
473
473
  "name": "title",
474
474
  "tags": [],
475
- "docs": "Title shown in the player (Android)\nby Manuel García Marín (https://github.com/PhantomPainX)",
475
+ "docs": "Title shown in the player and Chromecast metadata (iOS, Android)\nby Manuel García Marín (https://github.com/PhantomPainX)",
476
476
  "complexTypes": [],
477
477
  "type": "string | undefined"
478
478
  },
479
479
  {
480
480
  "name": "smallTitle",
481
481
  "tags": [],
482
- "docs": "Subtitle shown below the title in the player (Android)\nby Manuel García Marín (https://github.com/PhantomPainX)",
482
+ "docs": "Subtitle shown below the title in the player and Chromecast metadata (iOS, Android)\nby Manuel García Marín (https://github.com/PhantomPainX)",
483
483
  "complexTypes": [],
484
484
  "type": "string | undefined"
485
485
  },
@@ -493,14 +493,14 @@
493
493
  {
494
494
  "name": "chromecast",
495
495
  "tags": [],
496
- "docs": "Chromecast enable/disable (Android)\nby Manuel García Marín (https://github.com/PhantomPainX)\ndefault: true",
496
+ "docs": "Chromecast enable/disable (iOS, Android)\niOS requires Google Cast SDK setup and local network Info.plist keys.\nby Manuel García Marín (https://github.com/PhantomPainX)\ndefault: true",
497
497
  "complexTypes": [],
498
498
  "type": "boolean | undefined"
499
499
  },
500
500
  {
501
501
  "name": "artwork",
502
502
  "tags": [],
503
- "docs": "Artwork url to be shown in Chromecast player\nby Manuel García Marín (https://github.com/PhantomPainX)\ndefault: \"\"",
503
+ "docs": "Artwork url to be shown in Chromecast player (iOS, Android)\nby Manuel García Marín (https://github.com/PhantomPainX)\ndefault: \"\"",
504
504
  "complexTypes": [],
505
505
  "type": "string | undefined"
506
506
  },
@@ -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
  }