@capgo/capacitor-media-session 7.0.7 → 7.1.0

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/README.md CHANGED
@@ -22,6 +22,7 @@ npx cap sync
22
22
  * [`setPlaybackState(...)`](#setplaybackstate)
23
23
  * [`setActionHandler(...)`](#setactionhandler)
24
24
  * [`setPositionState(...)`](#setpositionstate)
25
+ * [`getPluginVersion()`](#getpluginversion)
25
26
  * [Interfaces](#interfaces)
26
27
  * [Type Aliases](#type-aliases)
27
28
 
@@ -91,6 +92,19 @@ Updates position state for the active media session.
91
92
  --------------------
92
93
 
93
94
 
95
+ ### getPluginVersion()
96
+
97
+ ```typescript
98
+ getPluginVersion() => Promise<{ version: string; }>
99
+ ```
100
+
101
+ Get the native Capacitor plugin version
102
+
103
+ **Returns:** <code>Promise&lt;{ version: string; }&gt;</code>
104
+
105
+ --------------------
106
+
107
+
94
108
  ### Interfaces
95
109
 
96
110
 
@@ -30,6 +30,8 @@ import org.json.JSONObject;
30
30
  @CapacitorPlugin(name = "MediaSession")
31
31
  public class MediaSessionPlugin extends Plugin {
32
32
 
33
+ private final String PLUGIN_VERSION = "7.1.0";
34
+
33
35
  private static final String TAG = "CapgoMediaSession";
34
36
 
35
37
  private boolean startServiceOnlyDuringPlayback = true;
@@ -274,4 +276,15 @@ public class MediaSessionPlugin extends Plugin {
274
276
  Log.d(TAG, "No handler for action " + action);
275
277
  }
276
278
  }
279
+
280
+ @PluginMethod
281
+ public void getPluginVersion(final PluginCall call) {
282
+ try {
283
+ final JSObject ret = new JSObject();
284
+ ret.put("version", this.PLUGIN_VERSION);
285
+ call.resolve(ret);
286
+ } catch (final Exception e) {
287
+ call.reject("Could not get plugin version", e);
288
+ }
289
+ }
277
290
  }
package/dist/docs.json CHANGED
@@ -82,6 +82,25 @@
82
82
  "PositionStateOptions"
83
83
  ],
84
84
  "slug": "setpositionstate"
85
+ },
86
+ {
87
+ "name": "getPluginVersion",
88
+ "signature": "() => Promise<{ version: string; }>",
89
+ "parameters": [],
90
+ "returns": "Promise<{ version: string; }>",
91
+ "tags": [
92
+ {
93
+ "name": "returns",
94
+ "text": "an Promise with version for this device"
95
+ },
96
+ {
97
+ "name": "throws",
98
+ "text": "An error if the something went wrong"
99
+ }
100
+ ],
101
+ "docs": "Get the native Capacitor plugin version",
102
+ "complexTypes": [],
103
+ "slug": "getpluginversion"
85
104
  }
86
105
  ],
87
106
  "properties": []
@@ -44,5 +44,14 @@ export interface MediaSessionPlugin {
44
44
  * Updates position state for the active media session.
45
45
  */
46
46
  setPositionState(options: PositionStateOptions): Promise<void>;
47
+ /**
48
+ * Get the native Capacitor plugin version
49
+ *
50
+ * @returns {Promise<{ id: string }>} an Promise with version for this device
51
+ * @throws An error if the something went wrong
52
+ */
53
+ getPluginVersion(): Promise<{
54
+ version: string;
55
+ }>;
47
56
  }
48
57
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface MediaImage {\n src: string;\n sizes?: string;\n type?: string;\n}\n\nexport type MediaSessionPlaybackState = 'none' | 'paused' | 'playing';\n\nexport type MediaSessionAction =\n | 'play'\n | 'pause'\n | 'seekbackward'\n | 'seekforward'\n | 'previoustrack'\n | 'nexttrack'\n | 'seekto'\n | 'stop';\n\nexport interface MetadataOptions {\n album?: string;\n artist?: string;\n artwork?: MediaImage[];\n title?: string;\n}\n\nexport interface PlaybackStateOptions {\n playbackState: MediaSessionPlaybackState;\n}\n\nexport interface ActionHandlerOptions {\n action: MediaSessionAction;\n}\n\nexport type ActionHandler = (details: ActionDetails) => void;\n\ninterface ActionDetails {\n action: MediaSessionAction;\n seekTime?: number | null;\n}\n\nexport interface PositionStateOptions {\n duration?: number;\n playbackRate?: number;\n position?: number;\n}\n\nexport interface MediaSessionPlugin {\n /**\n * Sets metadata of the currently playing media.\n */\n setMetadata(options: MetadataOptions): Promise<void>;\n /**\n * Updates the playback state of the media session.\n */\n setPlaybackState(options: PlaybackStateOptions): Promise<void>;\n /**\n * Registers a handler for a media session action.\n */\n setActionHandler(options: ActionHandlerOptions, handler: ActionHandler | null): Promise<void>;\n /**\n * Updates position state for the active media session.\n */\n setPositionState(options: PositionStateOptions): Promise<void>;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface MediaImage {\n src: string;\n sizes?: string;\n type?: string;\n}\n\nexport type MediaSessionPlaybackState = 'none' | 'paused' | 'playing';\n\nexport type MediaSessionAction =\n | 'play'\n | 'pause'\n | 'seekbackward'\n | 'seekforward'\n | 'previoustrack'\n | 'nexttrack'\n | 'seekto'\n | 'stop';\n\nexport interface MetadataOptions {\n album?: string;\n artist?: string;\n artwork?: MediaImage[];\n title?: string;\n}\n\nexport interface PlaybackStateOptions {\n playbackState: MediaSessionPlaybackState;\n}\n\nexport interface ActionHandlerOptions {\n action: MediaSessionAction;\n}\n\nexport type ActionHandler = (details: ActionDetails) => void;\n\ninterface ActionDetails {\n action: MediaSessionAction;\n seekTime?: number | null;\n}\n\nexport interface PositionStateOptions {\n duration?: number;\n playbackRate?: number;\n position?: number;\n}\n\nexport interface MediaSessionPlugin {\n /**\n * Sets metadata of the currently playing media.\n */\n setMetadata(options: MetadataOptions): Promise<void>;\n /**\n * Updates the playback state of the media session.\n */\n setPlaybackState(options: PlaybackStateOptions): Promise<void>;\n /**\n * Registers a handler for a media session action.\n */\n setActionHandler(options: ActionHandlerOptions, handler: ActionHandler | null): Promise<void>;\n /**\n * Updates position state for the active media session.\n */\n setPositionState(options: PositionStateOptions): Promise<void>;\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}\n"]}
package/dist/esm/web.d.ts CHANGED
@@ -5,4 +5,7 @@ export declare class MediaSessionWeb extends WebPlugin implements MediaSessionPl
5
5
  setPlaybackState(options: PlaybackStateOptions): Promise<void>;
6
6
  setActionHandler(options: ActionHandlerOptions, handler: ActionHandler | null): Promise<void>;
7
7
  setPositionState(options: PositionStateOptions): Promise<void>;
8
+ getPluginVersion(): Promise<{
9
+ version: string;
10
+ }>;
8
11
  }
package/dist/esm/web.js CHANGED
@@ -34,5 +34,8 @@ export class MediaSessionWeb extends WebPlugin {
34
34
  }
35
35
  mediaSession.setPositionState(options);
36
36
  }
37
+ async getPluginVersion() {
38
+ return { version: 'web' };
39
+ }
37
40
  }
38
41
  //# sourceMappingURL=web.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAW5C,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5C,KAAK,CAAC,WAAW,CAAC,OAAwB;QACxC,MAAM,YAAY,GAAI,SAAiB,CAAC,YAAY,CAAC;QACrD,IAAI,CAAC,YAAY,EAAE;YACjB,MAAM,IAAI,CAAC,WAAW,CAAC,kDAAkD,CAAC,CAAC;SAC5E;QAED,MAAM,iBAAiB,GAAI,MAAc,CAAC,aAAa,CAAC;QACxD,IAAI,iBAAiB,EAAE;YACrB,YAAY,CAAC,QAAQ,GAAG,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC;SACxD;aAAM;YACL,YAAY,CAAC,QAAQ,GAAG,OAAO,CAAC;SACjC;IACH,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,OAA6B;QAClD,MAAM,YAAY,GAAI,SAAiB,CAAC,YAAY,CAAC;QACrD,IAAI,CAAC,YAAY,EAAE;YACjB,MAAM,IAAI,CAAC,WAAW,CAAC,kDAAkD,CAAC,CAAC;SAC5E;QACD,YAAY,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,OAA6B,EAAE,OAA6B;QACjF,MAAM,YAAY,GAAI,SAAiB,CAAC,YAAY,CAAC;QACrD,IAAI,CAAC,YAAY,EAAE;YACjB,MAAM,IAAI,CAAC,WAAW,CAAC,kDAAkD,CAAC,CAAC;SAC5E;QACD,YAAY,CAAC,gBAAgB,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,OAA6B;QAClD,MAAM,YAAY,GAAI,SAAiB,CAAC,YAAY,CAAC;QACrD,IAAI,CAAC,YAAY,EAAE;YACjB,MAAM,IAAI,CAAC,WAAW,CAAC,kDAAkD,CAAC,CAAC;SAC5E;QACD,YAAY,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n ActionHandler,\n ActionHandlerOptions,\n MediaSessionPlugin,\n MetadataOptions,\n PlaybackStateOptions,\n PositionStateOptions,\n} from './definitions';\n\nexport class MediaSessionWeb extends WebPlugin implements MediaSessionPlugin {\n async setMetadata(options: MetadataOptions): Promise<void> {\n const mediaSession = (navigator as any).mediaSession;\n if (!mediaSession) {\n throw this.unavailable('Media Session API not available in this browser.');\n }\n\n const MediaMetadataCtor = (window as any).MediaMetadata;\n if (MediaMetadataCtor) {\n mediaSession.metadata = new MediaMetadataCtor(options);\n } else {\n mediaSession.metadata = options;\n }\n }\n\n async setPlaybackState(options: PlaybackStateOptions): Promise<void> {\n const mediaSession = (navigator as any).mediaSession;\n if (!mediaSession) {\n throw this.unavailable('Media Session API not available in this browser.');\n }\n mediaSession.playbackState = options.playbackState;\n }\n\n async setActionHandler(options: ActionHandlerOptions, handler: ActionHandler | null): Promise<void> {\n const mediaSession = (navigator as any).mediaSession;\n if (!mediaSession) {\n throw this.unavailable('Media Session API not available in this browser.');\n }\n mediaSession.setActionHandler(options.action, handler);\n }\n\n async setPositionState(options: PositionStateOptions): Promise<void> {\n const mediaSession = (navigator as any).mediaSession;\n if (!mediaSession) {\n throw this.unavailable('Media Session API not available in this browser.');\n }\n mediaSession.setPositionState(options);\n }\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAW5C,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5C,KAAK,CAAC,WAAW,CAAC,OAAwB;QACxC,MAAM,YAAY,GAAI,SAAiB,CAAC,YAAY,CAAC;QACrD,IAAI,CAAC,YAAY,EAAE;YACjB,MAAM,IAAI,CAAC,WAAW,CAAC,kDAAkD,CAAC,CAAC;SAC5E;QAED,MAAM,iBAAiB,GAAI,MAAc,CAAC,aAAa,CAAC;QACxD,IAAI,iBAAiB,EAAE;YACrB,YAAY,CAAC,QAAQ,GAAG,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC;SACxD;aAAM;YACL,YAAY,CAAC,QAAQ,GAAG,OAAO,CAAC;SACjC;IACH,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,OAA6B;QAClD,MAAM,YAAY,GAAI,SAAiB,CAAC,YAAY,CAAC;QACrD,IAAI,CAAC,YAAY,EAAE;YACjB,MAAM,IAAI,CAAC,WAAW,CAAC,kDAAkD,CAAC,CAAC;SAC5E;QACD,YAAY,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,OAA6B,EAAE,OAA6B;QACjF,MAAM,YAAY,GAAI,SAAiB,CAAC,YAAY,CAAC;QACrD,IAAI,CAAC,YAAY,EAAE;YACjB,MAAM,IAAI,CAAC,WAAW,CAAC,kDAAkD,CAAC,CAAC;SAC5E;QACD,YAAY,CAAC,gBAAgB,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,OAA6B;QAClD,MAAM,YAAY,GAAI,SAAiB,CAAC,YAAY,CAAC;QACrD,IAAI,CAAC,YAAY,EAAE;YACjB,MAAM,IAAI,CAAC,WAAW,CAAC,kDAAkD,CAAC,CAAC;SAC5E;QACD,YAAY,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n ActionHandler,\n ActionHandlerOptions,\n MediaSessionPlugin,\n MetadataOptions,\n PlaybackStateOptions,\n PositionStateOptions,\n} from './definitions';\n\nexport class MediaSessionWeb extends WebPlugin implements MediaSessionPlugin {\n async setMetadata(options: MetadataOptions): Promise<void> {\n const mediaSession = (navigator as any).mediaSession;\n if (!mediaSession) {\n throw this.unavailable('Media Session API not available in this browser.');\n }\n\n const MediaMetadataCtor = (window as any).MediaMetadata;\n if (MediaMetadataCtor) {\n mediaSession.metadata = new MediaMetadataCtor(options);\n } else {\n mediaSession.metadata = options;\n }\n }\n\n async setPlaybackState(options: PlaybackStateOptions): Promise<void> {\n const mediaSession = (navigator as any).mediaSession;\n if (!mediaSession) {\n throw this.unavailable('Media Session API not available in this browser.');\n }\n mediaSession.playbackState = options.playbackState;\n }\n\n async setActionHandler(options: ActionHandlerOptions, handler: ActionHandler | null): Promise<void> {\n const mediaSession = (navigator as any).mediaSession;\n if (!mediaSession) {\n throw this.unavailable('Media Session API not available in this browser.');\n }\n mediaSession.setActionHandler(options.action, handler);\n }\n\n async setPositionState(options: PositionStateOptions): Promise<void> {\n const mediaSession = (navigator as any).mediaSession;\n if (!mediaSession) {\n throw this.unavailable('Media Session API not available in this browser.');\n }\n mediaSession.setPositionState(options);\n }\n\n async getPluginVersion(): Promise<{ version: string }> {\n return { version: 'web' };\n }\n}\n"]}
@@ -42,6 +42,9 @@ class MediaSessionWeb extends core.WebPlugin {
42
42
  }
43
43
  mediaSession.setPositionState(options);
44
44
  }
45
+ async getPluginVersion() {
46
+ return { version: 'web' };
47
+ }
45
48
  }
46
49
 
47
50
  var web = /*#__PURE__*/Object.freeze({
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst MediaSession = registerPlugin('MediaSession', {\n web: () => import('./web').then((m) => new m.MediaSessionWeb()),\n ios: () => import('./web').then((m) => new m.MediaSessionWeb()),\n});\nexport * from './definitions';\nexport { MediaSession };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class MediaSessionWeb extends WebPlugin {\n async setMetadata(options) {\n const mediaSession = navigator.mediaSession;\n if (!mediaSession) {\n throw this.unavailable('Media Session API not available in this browser.');\n }\n const MediaMetadataCtor = window.MediaMetadata;\n if (MediaMetadataCtor) {\n mediaSession.metadata = new MediaMetadataCtor(options);\n }\n else {\n mediaSession.metadata = options;\n }\n }\n async setPlaybackState(options) {\n const mediaSession = navigator.mediaSession;\n if (!mediaSession) {\n throw this.unavailable('Media Session API not available in this browser.');\n }\n mediaSession.playbackState = options.playbackState;\n }\n async setActionHandler(options, handler) {\n const mediaSession = navigator.mediaSession;\n if (!mediaSession) {\n throw this.unavailable('Media Session API not available in this browser.');\n }\n mediaSession.setActionHandler(options.action, handler);\n }\n async setPositionState(options) {\n const mediaSession = navigator.mediaSession;\n if (!mediaSession) {\n throw this.unavailable('Media Session API not available in this browser.');\n }\n mediaSession.setPositionState(options);\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,YAAY,GAAGA,mBAAc,CAAC,cAAc,EAAE;AACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;AACnE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CA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AI,CAAC,YAAY,EAAE;AAC3B,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,kDAAkD,CAAC;AACtF,QAAQ;AACR,QAAQ,YAAY,CAAC,gBAAgB,CAAC,OAAO,CAAC;AAC9C,IAAI;AACJ;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst MediaSession = registerPlugin('MediaSession', {\n web: () => import('./web').then((m) => new m.MediaSessionWeb()),\n ios: () => import('./web').then((m) => new m.MediaSessionWeb()),\n});\nexport * from './definitions';\nexport { MediaSession };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class MediaSessionWeb extends WebPlugin {\n async setMetadata(options) {\n const mediaSession = navigator.mediaSession;\n if (!mediaSession) {\n throw this.unavailable('Media Session API not available in this browser.');\n }\n const MediaMetadataCtor = window.MediaMetadata;\n if (MediaMetadataCtor) {\n mediaSession.metadata = new MediaMetadataCtor(options);\n }\n else {\n mediaSession.metadata = options;\n }\n }\n async setPlaybackState(options) {\n const mediaSession = navigator.mediaSession;\n if (!mediaSession) {\n throw this.unavailable('Media Session API not available in this browser.');\n }\n mediaSession.playbackState = options.playbackState;\n }\n async setActionHandler(options, handler) {\n const mediaSession = navigator.mediaSession;\n if (!mediaSession) {\n throw this.unavailable('Media Session API not available in this browser.');\n }\n mediaSession.setActionHandler(options.action, handler);\n }\n async setPositionState(options) {\n const mediaSession = navigator.mediaSession;\n if (!mediaSession) {\n throw this.unavailable('Media Session API not available in this browser.');\n }\n mediaSession.setPositionState(options);\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,YAAY,GAAGA,mBAAc,CAAC,cAAc,EAAE;AACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,C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AC,OAAO,EAAE;AACpC,QAAQ,MAAM,YAAY,GAAG,SAAS,CAAC,YAAY;AACnD,QAAQ,IAAI,CAAC,YAAY,EAAE;AAC3B,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,kDAAkD,CAAC;AACtF,QAAQ;AACR,QAAQ,YAAY,CAAC,gBAAgB,CAAC,OAAO,CAAC;AAC9C,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ;;;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -41,6 +41,9 @@ var capacitorMediaSession = (function (exports, core) {
41
41
  }
42
42
  mediaSession.setPositionState(options);
43
43
  }
44
+ async getPluginVersion() {
45
+ return { version: 'web' };
46
+ }
44
47
  }
45
48
 
46
49
  var web = /*#__PURE__*/Object.freeze({
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst MediaSession = registerPlugin('MediaSession', {\n web: () => import('./web').then((m) => new m.MediaSessionWeb()),\n ios: () => import('./web').then((m) => new m.MediaSessionWeb()),\n});\nexport * from './definitions';\nexport { MediaSession };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class MediaSessionWeb extends WebPlugin {\n async setMetadata(options) {\n const mediaSession = navigator.mediaSession;\n if (!mediaSession) {\n throw this.unavailable('Media Session API not available in this browser.');\n }\n const MediaMetadataCtor = window.MediaMetadata;\n if (MediaMetadataCtor) {\n mediaSession.metadata = new MediaMetadataCtor(options);\n }\n else {\n mediaSession.metadata = options;\n }\n }\n async setPlaybackState(options) {\n const mediaSession = navigator.mediaSession;\n if (!mediaSession) {\n throw this.unavailable('Media Session API not available in this browser.');\n }\n mediaSession.playbackState = options.playbackState;\n }\n async setActionHandler(options, handler) {\n const mediaSession = navigator.mediaSession;\n if (!mediaSession) {\n throw this.unavailable('Media Session API not available in this browser.');\n }\n mediaSession.setActionHandler(options.action, handler);\n }\n async setPositionState(options) {\n const mediaSession = navigator.mediaSession;\n if (!mediaSession) {\n throw this.unavailable('Media Session API not available in this browser.');\n }\n mediaSession.setPositionState(options);\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,YAAY,GAAGA,mBAAc,CAAC,cAAc,EAAE;IACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACnE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACnE,CAAC;;ICHM,MAAM,eAAe,SAASC,cAAS,CAAC;IAC/C,IAAI,MAAM,WAAW,CAAC,OAAO,EAAE;IAC/B,QAAQ,MAAM,YAAY,GAAG,SAAS,CAAC,YAAY;IACnD,QAAQ,IAAI,CAAC,YAAY,EAAE;IAC3B,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,kDAAkD,CAAC;IACtF,QAAQ;IACR,QAAQ,MAAM,iBAAiB,GAAG,MAAM,CAAC,aAAa;IACtD,QAAQ,IAAI,iBAAiB,EAAE;IAC/B,YAAY,YAAY,CAAC,QAAQ,GAAG,IAAI,iBAAiB,CAAC,OAAO,CAAC;IAClE,QAAQ;IACR,aAAa;IACb,YAAY,YAAY,CAAC,QAAQ,GAAG,OAAO;IAC3C,QAAQ;IACR,IAAI;IACJ,IAAI,MAAM,gBAAgB,CAAC,OAAO,EAAE;IACpC,QAAQ,MAAM,YAAY,GAAG,SAAS,CAAC,YAAY;IACnD,QAAQ,IAAI,CAAC,YAAY,EAAE;IAC3B,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,kDAAkD,CAAC;IACtF,QAAQ;IACR,QAAQ,YAAY,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa;IAC1D,IAAI;IACJ,IAAI,MAAM,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE;IAC7C,QAAQ,MAAM,YAAY,GAAG,SAAS,CAAC,YAAY;IACnD,QAAQ,IAAI,CAAC,YAAY,EAAE;IAC3B,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,kDAAkD,CAAC;IACtF,QAAQ;IACR,QAAQ,YAAY,CAAC,gBAAgB,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC;IAC9D,IAAI;IACJ,IAAI,MAAM,gBAAgB,CAAC,OAAO,EAAE;IACpC,QAAQ,MAAM,YAAY,GAAG,SAAS,CAAC,YAAY;IACnD,QAAQ,IAAI,CAAC,YAAY,EAAE;IAC3B,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,kDAAkD,CAAC;IACtF,QAAQ;IACR,QAAQ,YAAY,CAAC,gBAAgB,CAAC,OAAO,CAAC;IAC9C,IAAI;IACJ;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst MediaSession = registerPlugin('MediaSession', {\n web: () => import('./web').then((m) => new m.MediaSessionWeb()),\n ios: () => import('./web').then((m) => new m.MediaSessionWeb()),\n});\nexport * from './definitions';\nexport { MediaSession };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class MediaSessionWeb extends WebPlugin {\n async setMetadata(options) {\n const mediaSession = navigator.mediaSession;\n if (!mediaSession) {\n throw this.unavailable('Media Session API not available in this browser.');\n }\n const MediaMetadataCtor = window.MediaMetadata;\n if (MediaMetadataCtor) {\n mediaSession.metadata = new MediaMetadataCtor(options);\n }\n else {\n mediaSession.metadata = options;\n }\n }\n async setPlaybackState(options) {\n const mediaSession = navigator.mediaSession;\n if (!mediaSession) {\n throw this.unavailable('Media Session API not available in this browser.');\n }\n mediaSession.playbackState = options.playbackState;\n }\n async setActionHandler(options, handler) {\n const mediaSession = navigator.mediaSession;\n if (!mediaSession) {\n throw this.unavailable('Media Session API not available in this browser.');\n }\n mediaSession.setActionHandler(options.action, handler);\n }\n async setPositionState(options) {\n const mediaSession = navigator.mediaSession;\n if (!mediaSession) {\n throw this.unavailable('Media Session API not available in this browser.');\n }\n mediaSession.setPositionState(options);\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,YAAY,GAAGA,mBAAc,CAAC,cAAc,EAAE;IACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACnE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACnE,CAAC;;ICHM,MAAM,eAAe,SAASC,cAAS,CAAC;IAC/C,IAAI,MAAM,WAAW,CAAC,OAAO,EAAE;IAC/B,QAAQ,MAAM,YAAY,GAAG,SAAS,CAAC,YAAY;IACnD,QAAQ,IAAI,CAAC,YAAY,EAAE;IAC3B,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,kDAAkD,CAAC;IACtF,QAAQ;IACR,QAAQ,MAAM,iBAAiB,GAAG,MAAM,CAAC,aAAa;IACtD,QAAQ,IAAI,iBAAiB,EAAE;IAC/B,YAAY,YAAY,CAAC,QAAQ,GAAG,IAAI,iBAAiB,CAAC,OAAO,CAAC;IAClE,QAAQ;IACR,aAAa;IACb,YAAY,YAAY,CAAC,QAAQ,GAAG,OAAO;IAC3C,QAAQ;IACR,IAAI;IACJ,IAAI,MAAM,gBAAgB,CAAC,OAAO,EAAE;IACpC,QAAQ,MAAM,YAAY,GAAG,SAAS,CAAC,YAAY;IACnD,QAAQ,IAAI,CAAC,YAAY,EAAE;IAC3B,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,kDAAkD,CAAC;IACtF,QAAQ;IACR,QAAQ,YAAY,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa;IAC1D,IAAI;IACJ,IAAI,MAAM,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE;IAC7C,QAAQ,MAAM,YAAY,GAAG,SAAS,CAAC,YAAY;IACnD,QAAQ,IAAI,CAAC,YAAY,EAAE;IAC3B,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,kDAAkD,CAAC;IACtF,QAAQ;IACR,QAAQ,YAAY,CAAC,gBAAgB,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC;IAC9D,IAAI;IACJ,IAAI,MAAM,gBAAgB,CAAC,OAAO,EAAE;IACpC,QAAQ,MAAM,YAAY,GAAG,SAAS,CAAC,YAAY;IACnD,QAAQ,IAAI,CAAC,YAAY,EAAE;IAC3B,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,kDAAkD,CAAC;IACtF,QAAQ;IACR,QAAQ,YAAY,CAAC,gBAAgB,CAAC,OAAO,CAAC;IAC9C,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ;;;;;;;;;;;;;;;"}
@@ -3,7 +3,15 @@ import Foundation
3
3
 
4
4
  @objc(MediaSessionPlugin)
5
5
  public class MediaSessionPlugin: CAPPlugin, CAPBridgedPlugin {
6
+ private let PLUGIN_VERSION: String = "7.1.0"
6
7
  public let identifier = "MediaSessionPlugin"
7
8
  public let jsName = "MediaSession"
8
- public let pluginMethods: [CAPPluginMethod] = []
9
+ public let pluginMethods: [CAPPluginMethod] = [
10
+ CAPPluginMethod(name: "getPluginVersion", returnType: CAPPluginReturnPromise)
11
+ ]
12
+
13
+ @objc func getPluginVersion(_ call: CAPPluginCall) {
14
+ call.resolve(["version": self.PLUGIN_VERSION])
15
+ }
16
+
9
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-media-session",
3
- "version": "7.0.7",
3
+ "version": "7.1.0",
4
4
  "description": "Capacitor plugin to expose media session controls of the device",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",