@capgo/native-audio 5.1.3 → 5.1.10

Sign up to get free protection for your applications and to get access to all the features.
package/dist/docs.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "methods": [
8
8
  {
9
9
  "name": "configure",
10
- "signature": "(options: ConfigureOptions) => any",
10
+ "signature": "(options: ConfigureOptions) => Promise<void>",
11
11
  "parameters": [
12
12
  {
13
13
  "name": "options",
@@ -15,7 +15,7 @@
15
15
  "type": "ConfigureOptions"
16
16
  }
17
17
  ],
18
- "returns": "any",
18
+ "returns": "Promise<void>",
19
19
  "tags": [],
20
20
  "docs": "",
21
21
  "complexTypes": [
@@ -25,7 +25,7 @@
25
25
  },
26
26
  {
27
27
  "name": "preload",
28
- "signature": "(options: PreloadOptions) => any",
28
+ "signature": "(options: PreloadOptions) => Promise<void>",
29
29
  "parameters": [
30
30
  {
31
31
  "name": "options",
@@ -33,7 +33,7 @@
33
33
  "type": "PreloadOptions"
34
34
  }
35
35
  ],
36
- "returns": "any",
36
+ "returns": "Promise<void>",
37
37
  "tags": [],
38
38
  "docs": "",
39
39
  "complexTypes": [
@@ -43,7 +43,7 @@
43
43
  },
44
44
  {
45
45
  "name": "play",
46
- "signature": "(options: { assetId: string; time?: number; }) => any",
46
+ "signature": "(options: { assetId: string; time?: number; }) => Promise<void>",
47
47
  "parameters": [
48
48
  {
49
49
  "name": "options",
@@ -51,7 +51,7 @@
51
51
  "type": "{ assetId: string; time?: number | undefined; }"
52
52
  }
53
53
  ],
54
- "returns": "any",
54
+ "returns": "Promise<void>",
55
55
  "tags": [],
56
56
  "docs": "",
57
57
  "complexTypes": [],
@@ -59,7 +59,7 @@
59
59
  },
60
60
  {
61
61
  "name": "pause",
62
- "signature": "(options: { assetId: string; }) => any",
62
+ "signature": "(options: { assetId: string; }) => Promise<void>",
63
63
  "parameters": [
64
64
  {
65
65
  "name": "options",
@@ -67,7 +67,7 @@
67
67
  "type": "{ assetId: string; }"
68
68
  }
69
69
  ],
70
- "returns": "any",
70
+ "returns": "Promise<void>",
71
71
  "tags": [],
72
72
  "docs": "",
73
73
  "complexTypes": [],
@@ -75,7 +75,7 @@
75
75
  },
76
76
  {
77
77
  "name": "resume",
78
- "signature": "(options: { assetId: string; }) => any",
78
+ "signature": "(options: { assetId: string; }) => Promise<void>",
79
79
  "parameters": [
80
80
  {
81
81
  "name": "options",
@@ -83,7 +83,7 @@
83
83
  "type": "{ assetId: string; }"
84
84
  }
85
85
  ],
86
- "returns": "any",
86
+ "returns": "Promise<void>",
87
87
  "tags": [],
88
88
  "docs": "",
89
89
  "complexTypes": [],
@@ -91,7 +91,7 @@
91
91
  },
92
92
  {
93
93
  "name": "loop",
94
- "signature": "(options: { assetId: string; }) => any",
94
+ "signature": "(options: { assetId: string; }) => Promise<void>",
95
95
  "parameters": [
96
96
  {
97
97
  "name": "options",
@@ -99,7 +99,7 @@
99
99
  "type": "{ assetId: string; }"
100
100
  }
101
101
  ],
102
- "returns": "any",
102
+ "returns": "Promise<void>",
103
103
  "tags": [],
104
104
  "docs": "",
105
105
  "complexTypes": [],
@@ -107,7 +107,7 @@
107
107
  },
108
108
  {
109
109
  "name": "stop",
110
- "signature": "(options: { assetId: string; }) => any",
110
+ "signature": "(options: { assetId: string; }) => Promise<void>",
111
111
  "parameters": [
112
112
  {
113
113
  "name": "options",
@@ -115,7 +115,7 @@
115
115
  "type": "{ assetId: string; }"
116
116
  }
117
117
  ],
118
- "returns": "any",
118
+ "returns": "Promise<void>",
119
119
  "tags": [],
120
120
  "docs": "",
121
121
  "complexTypes": [],
@@ -123,7 +123,7 @@
123
123
  },
124
124
  {
125
125
  "name": "unload",
126
- "signature": "(options: { assetId: string; }) => any",
126
+ "signature": "(options: { assetId: string; }) => Promise<void>",
127
127
  "parameters": [
128
128
  {
129
129
  "name": "options",
@@ -131,7 +131,7 @@
131
131
  "type": "{ assetId: string; }"
132
132
  }
133
133
  ],
134
- "returns": "any",
134
+ "returns": "Promise<void>",
135
135
  "tags": [],
136
136
  "docs": "",
137
137
  "complexTypes": [],
@@ -139,7 +139,7 @@
139
139
  },
140
140
  {
141
141
  "name": "setVolume",
142
- "signature": "(options: { assetId: string; volume: number; }) => any",
142
+ "signature": "(options: { assetId: string; volume: number; }) => Promise<void>",
143
143
  "parameters": [
144
144
  {
145
145
  "name": "options",
@@ -147,7 +147,7 @@
147
147
  "type": "{ assetId: string; volume: number; }"
148
148
  }
149
149
  ],
150
- "returns": "any",
150
+ "returns": "Promise<void>",
151
151
  "tags": [],
152
152
  "docs": "",
153
153
  "complexTypes": [],
@@ -155,7 +155,7 @@
155
155
  },
156
156
  {
157
157
  "name": "setRate",
158
- "signature": "(options: { assetId: string; rate: number; }) => any",
158
+ "signature": "(options: { assetId: string; rate: number; }) => Promise<void>",
159
159
  "parameters": [
160
160
  {
161
161
  "name": "options",
@@ -163,7 +163,7 @@
163
163
  "type": "{ assetId: string; rate: number; }"
164
164
  }
165
165
  ],
166
- "returns": "any",
166
+ "returns": "Promise<void>",
167
167
  "tags": [],
168
168
  "docs": "",
169
169
  "complexTypes": [],
@@ -171,7 +171,7 @@
171
171
  },
172
172
  {
173
173
  "name": "getCurrentTime",
174
- "signature": "(options: { assetId: string; }) => any",
174
+ "signature": "(options: { assetId: string; }) => Promise<{ currentTime: number; }>",
175
175
  "parameters": [
176
176
  {
177
177
  "name": "options",
@@ -179,7 +179,7 @@
179
179
  "type": "{ assetId: string; }"
180
180
  }
181
181
  ],
182
- "returns": "any",
182
+ "returns": "Promise<{ currentTime: number; }>",
183
183
  "tags": [],
184
184
  "docs": "",
185
185
  "complexTypes": [],
@@ -187,7 +187,7 @@
187
187
  },
188
188
  {
189
189
  "name": "getDuration",
190
- "signature": "(options: { assetId: string; }) => any",
190
+ "signature": "(options: { assetId: string; }) => Promise<{ duration: number; }>",
191
191
  "parameters": [
192
192
  {
193
193
  "name": "options",
@@ -195,7 +195,7 @@
195
195
  "type": "{ assetId: string; }"
196
196
  }
197
197
  ],
198
- "returns": "any",
198
+ "returns": "Promise<{ duration: number; }>",
199
199
  "tags": [],
200
200
  "docs": "",
201
201
  "complexTypes": [],
@@ -203,7 +203,7 @@
203
203
  },
204
204
  {
205
205
  "name": "isPlaying",
206
- "signature": "(options: { assetId: string; }) => any",
206
+ "signature": "(options: { assetId: string; }) => Promise<{ isPlaying: boolean; }>",
207
207
  "parameters": [
208
208
  {
209
209
  "name": "options",
@@ -211,7 +211,7 @@
211
211
  "type": "{ assetId: string; }"
212
212
  }
213
213
  ],
214
- "returns": "any",
214
+ "returns": "Promise<{ isPlaying: boolean; }>",
215
215
  "tags": [],
216
216
  "docs": "",
217
217
  "complexTypes": [],
@@ -1,4 +1,4 @@
1
- import { NativeAudio } from './definitions';
1
+ import { NativeAudio } from "./definitions";
2
2
  declare const NativeAudio: NativeAudio;
3
- export * from './definitions';
3
+ export * from "./definitions";
4
4
  export { NativeAudio };
package/dist/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { registerPlugin } from '@capacitor/core';
2
- const NativeAudio = registerPlugin('NativeAudio', {
3
- web: () => import('./web').then((m) => new m.NativeAudioWeb()),
1
+ import { registerPlugin } from "@capacitor/core";
2
+ const NativeAudio = registerPlugin("NativeAudio", {
3
+ web: () => import("./web").then((m) => new m.NativeAudioWeb()),
4
4
  });
5
- export * from './definitions';
5
+ export * from "./definitions";
6
6
  export { NativeAudio };
7
7
  //# sourceMappingURL=index.js.map
package/dist/esm/web.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { WebPlugin } from '@capacitor/core';
2
- import type { ConfigureOptions, PreloadOptions } from './definitions';
3
- import { NativeAudio } from './definitions';
1
+ import { WebPlugin } from "@capacitor/core";
2
+ import type { ConfigureOptions, PreloadOptions } from "./definitions";
3
+ import { NativeAudio } from "./definitions";
4
4
  export declare class NativeAudioWeb extends WebPlugin implements NativeAudio {
5
5
  private static readonly FILE_LOCATION;
6
6
  private static readonly AUDIO_ASSET_BY_ASSET_ID;
package/dist/esm/web.js CHANGED
@@ -1,10 +1,10 @@
1
- import { WebPlugin } from '@capacitor/core';
2
- import { AudioAsset } from './audio-asset';
1
+ import { WebPlugin } from "@capacitor/core";
2
+ import { AudioAsset } from "./audio-asset";
3
3
  export class NativeAudioWeb extends WebPlugin {
4
4
  constructor() {
5
5
  super({
6
- name: 'NativeAudio',
7
- platforms: ['web'],
6
+ name: "NativeAudio",
7
+ platforms: ["web"],
8
8
  });
9
9
  }
10
10
  async resume(options) {
@@ -24,10 +24,10 @@ export class NativeAudioWeb extends WebPlugin {
24
24
  async getDuration(options) {
25
25
  const audio = this.getAudioAsset(options.assetId).audio;
26
26
  if (Number.isNaN(audio.duration)) {
27
- throw 'no duration available';
27
+ throw "no duration available";
28
28
  }
29
29
  if (!Number.isFinite(audio.duration)) {
30
- throw 'duration not available => media resource is streaming';
30
+ throw "duration not available => media resource is streaming";
31
31
  }
32
32
  return { duration: audio.duration };
33
33
  }
@@ -37,19 +37,20 @@ export class NativeAudioWeb extends WebPlugin {
37
37
  async preload(options) {
38
38
  var _a;
39
39
  if (NativeAudioWeb.AUDIO_ASSET_BY_ASSET_ID.has(options.assetId)) {
40
- throw 'AssetId already exists. Unload first if like to change!';
40
+ throw "AssetId already exists. Unload first if like to change!";
41
41
  }
42
42
  if (!((_a = options.assetPath) === null || _a === void 0 ? void 0 : _a.length)) {
43
- throw 'no assetPath provided';
43
+ throw "no assetPath provided";
44
44
  }
45
- if (!options.isUrl && !new RegExp('^/?' + NativeAudioWeb.FILE_LOCATION).test(options.assetPath)) {
46
- const slashPrefix = options.assetPath.startsWith('/') ? '' : '/';
45
+ if (!options.isUrl &&
46
+ !new RegExp("^/?" + NativeAudioWeb.FILE_LOCATION).test(options.assetPath)) {
47
+ const slashPrefix = options.assetPath.startsWith("/") ? "" : "/";
47
48
  options.assetPath = `${NativeAudioWeb.FILE_LOCATION}${slashPrefix}${options.assetPath}`;
48
49
  }
49
50
  const audio = new Audio(options.assetPath);
50
51
  audio.autoplay = false;
51
52
  audio.loop = false;
52
- audio.preload = 'auto';
53
+ audio.preload = "auto";
53
54
  if (options.volume) {
54
55
  audio.volume = options.volume;
55
56
  }
@@ -80,15 +81,15 @@ export class NativeAudioWeb extends WebPlugin {
80
81
  NativeAudioWeb.AUDIO_ASSET_BY_ASSET_ID.delete(options.assetId);
81
82
  }
82
83
  async setVolume(options) {
83
- if (typeof (options === null || options === void 0 ? void 0 : options.volume) !== 'number') {
84
- throw 'no volume provided';
84
+ if (typeof (options === null || options === void 0 ? void 0 : options.volume) !== "number") {
85
+ throw "no volume provided";
85
86
  }
86
87
  const audio = this.getAudioAsset(options.assetId).audio;
87
88
  audio.volume = options.volume;
88
89
  }
89
90
  async setRate(options) {
90
- if (typeof (options === null || options === void 0 ? void 0 : options.rate) !== 'number') {
91
- throw 'no rate provided';
91
+ if (typeof (options === null || options === void 0 ? void 0 : options.rate) !== "number") {
92
+ throw "no rate provided";
92
93
  }
93
94
  const audio = this.getAudioAsset(options.assetId).audio;
94
95
  audio.playbackRate = options.rate;
@@ -105,15 +106,15 @@ export class NativeAudioWeb extends WebPlugin {
105
106
  return NativeAudioWeb.AUDIO_ASSET_BY_ASSET_ID.get(assetId);
106
107
  }
107
108
  checkAssetId(assetId) {
108
- if (typeof assetId !== 'string') {
109
- throw 'assetId must be a string';
109
+ if (typeof assetId !== "string") {
110
+ throw "assetId must be a string";
110
111
  }
111
112
  if (!(assetId === null || assetId === void 0 ? void 0 : assetId.length)) {
112
- throw 'no assetId provided';
113
+ throw "no assetId provided";
113
114
  }
114
115
  }
115
116
  }
116
- NativeAudioWeb.FILE_LOCATION = '';
117
+ NativeAudioWeb.FILE_LOCATION = "";
117
118
  NativeAudioWeb.AUDIO_ASSET_BY_ASSET_ID = new Map();
118
119
  const NativeAudio = new NativeAudioWeb();
119
120
  export { NativeAudio };
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,MAAM,e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AC;SAC7B;IACH,CAAC;;AAhJuB,4BAAa,GAAW,EAAE,CAAC;AAC3B,sCAAuB,GAC7C,IAAI,GAAG,EAAsB,CAAC;AAiJlC,MAAM,WAAW,GAAG,IAAI,cAAc,EAAE,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -2,7 +2,7 @@
2
2
 
3
3
  var core = require('@capacitor/core');
4
4
 
5
- const NativeAudio$1 = core.registerPlugin('NativeAudio', {
5
+ const NativeAudio$1 = core.registerPlugin("NativeAudio", {
6
6
  web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.NativeAudioWeb()),
7
7
  });
8
8
 
@@ -15,8 +15,8 @@ class AudioAsset {
15
15
  class NativeAudioWeb extends core.WebPlugin {
16
16
  constructor() {
17
17
  super({
18
- name: 'NativeAudio',
19
- platforms: ['web'],
18
+ name: "NativeAudio",
19
+ platforms: ["web"],
20
20
  });
21
21
  }
22
22
  async resume(options) {
@@ -36,10 +36,10 @@ class NativeAudioWeb extends core.WebPlugin {
36
36
  async getDuration(options) {
37
37
  const audio = this.getAudioAsset(options.assetId).audio;
38
38
  if (Number.isNaN(audio.duration)) {
39
- throw 'no duration available';
39
+ throw "no duration available";
40
40
  }
41
41
  if (!Number.isFinite(audio.duration)) {
42
- throw 'duration not available => media resource is streaming';
42
+ throw "duration not available => media resource is streaming";
43
43
  }
44
44
  return { duration: audio.duration };
45
45
  }
@@ -49,19 +49,20 @@ class NativeAudioWeb extends core.WebPlugin {
49
49
  async preload(options) {
50
50
  var _a;
51
51
  if (NativeAudioWeb.AUDIO_ASSET_BY_ASSET_ID.has(options.assetId)) {
52
- throw 'AssetId already exists. Unload first if like to change!';
52
+ throw "AssetId already exists. Unload first if like to change!";
53
53
  }
54
54
  if (!((_a = options.assetPath) === null || _a === void 0 ? void 0 : _a.length)) {
55
- throw 'no assetPath provided';
55
+ throw "no assetPath provided";
56
56
  }
57
- if (!options.isUrl && !new RegExp('^/?' + NativeAudioWeb.FILE_LOCATION).test(options.assetPath)) {
58
- const slashPrefix = options.assetPath.startsWith('/') ? '' : '/';
57
+ if (!options.isUrl &&
58
+ !new RegExp("^/?" + NativeAudioWeb.FILE_LOCATION).test(options.assetPath)) {
59
+ const slashPrefix = options.assetPath.startsWith("/") ? "" : "/";
59
60
  options.assetPath = `${NativeAudioWeb.FILE_LOCATION}${slashPrefix}${options.assetPath}`;
60
61
  }
61
62
  const audio = new Audio(options.assetPath);
62
63
  audio.autoplay = false;
63
64
  audio.loop = false;
64
- audio.preload = 'auto';
65
+ audio.preload = "auto";
65
66
  if (options.volume) {
66
67
  audio.volume = options.volume;
67
68
  }
@@ -92,15 +93,15 @@ class NativeAudioWeb extends core.WebPlugin {
92
93
  NativeAudioWeb.AUDIO_ASSET_BY_ASSET_ID.delete(options.assetId);
93
94
  }
94
95
  async setVolume(options) {
95
- if (typeof (options === null || options === void 0 ? void 0 : options.volume) !== 'number') {
96
- throw 'no volume provided';
96
+ if (typeof (options === null || options === void 0 ? void 0 : options.volume) !== "number") {
97
+ throw "no volume provided";
97
98
  }
98
99
  const audio = this.getAudioAsset(options.assetId).audio;
99
100
  audio.volume = options.volume;
100
101
  }
101
102
  async setRate(options) {
102
- if (typeof (options === null || options === void 0 ? void 0 : options.rate) !== 'number') {
103
- throw 'no rate provided';
103
+ if (typeof (options === null || options === void 0 ? void 0 : options.rate) !== "number") {
104
+ throw "no rate provided";
104
105
  }
105
106
  const audio = this.getAudioAsset(options.assetId).audio;
106
107
  audio.playbackRate = options.rate;
@@ -117,15 +118,15 @@ class NativeAudioWeb extends core.WebPlugin {
117
118
  return NativeAudioWeb.AUDIO_ASSET_BY_ASSET_ID.get(assetId);
118
119
  }
119
120
  checkAssetId(assetId) {
120
- if (typeof assetId !== 'string') {
121
- throw 'assetId must be a string';
121
+ if (typeof assetId !== "string") {
122
+ throw "assetId must be a string";
122
123
  }
123
124
  if (!(assetId === null || assetId === void 0 ? void 0 : assetId.length)) {
124
- throw 'no assetId provided';
125
+ throw "no assetId provided";
125
126
  }
126
127
  }
127
128
  }
128
- NativeAudioWeb.FILE_LOCATION = '';
129
+ NativeAudioWeb.FILE_LOCATION = "";
129
130
  NativeAudioWeb.AUDIO_ASSET_BY_ASSET_ID = new Map();
130
131
  const NativeAudio = new NativeAudioWeb();
131
132
 
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/audio-asset.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst NativeAudio = registerPlugin('NativeAudio', {\n web: () => import('./web').then((m) => new m.NativeAudioWeb()),\n});\nexport * from './definitions';\nexport { NativeAudio };\n//# sourceMappingURL=index.js.map","export class AudioAsset {\n constructor(audio) {\n this.audio = audio;\n }\n}\n//# sourceMappingURL=audio-asset.js.map","import { WebPlugin } from '@capacitor/core';\nimport { AudioAsset } from './audio-asset';\nexport class NativeAudioWeb extends WebPlugin {\n constructor() {\n super({\n name: 'NativeAudio',\n platforms: ['web'],\n });\n }\n async resume(options) {\n const audio = this.getAudioAsset(options.assetId).audio;\n if (audio.paused) {\n return audio.play();\n }\n }\n async pause(options) {\n const audio = this.getAudioAsset(options.assetId).audio;\n return audio.pause();\n }\n async getCurrentTime(options) {\n const audio = this.getAudioAsset(options.assetId).audio;\n return { currentTime: audio.currentTime };\n }\n async getDuration(options) {\n const audio = this.getAudioAsset(options.assetId).audio;\n if (Number.isNaN(audio.duration)) {\n throw 'no duration available';\n }\n if (!Number.isFinite(audio.duration)) {\n throw 'duration not available => media resource is streaming';\n }\n return { duration: audio.duration };\n }\n async configure(options) {\n throw `configure is not supported for web: ${JSON.stringify(options)}`;\n }\n async preload(options) {\n var _a;\n if (NativeAudioWeb.AUDIO_ASSET_BY_ASSET_ID.has(options.assetId)) {\n throw 'AssetId already exists. Unload first if like to change!';\n }\n if (!((_a = options.assetPath) === null || _a === void 0 ? void 0 : _a.length)) {\n throw 'no assetPath provided';\n }\n if (!options.isUrl && !new RegExp('^/?' + NativeAudioWeb.FILE_LOCATION).test(options.assetPath)) {\n const slashPrefix = options.assetPath.startsWith('/') ? '' : '/';\n options.assetPath = `${NativeAudioWeb.FILE_LOCATION}${slashPrefix}${options.assetPath}`;\n }\n const audio = new Audio(options.assetPath);\n audio.autoplay = false;\n audio.loop = false;\n audio.preload = 'auto';\n if (options.volume) {\n audio.volume = options.volume;\n }\n NativeAudioWeb.AUDIO_ASSET_BY_ASSET_ID.set(options.assetId, new AudioAsset(audio));\n }\n async play(options) {\n var _a;\n const audio = this.getAudioAsset(options.assetId).audio;\n await this.stop(options);\n audio.loop = false;\n audio.currentTime = (_a = options.time) !== null && _a !== void 0 ? _a : 0;\n return audio.play();\n }\n async loop(options) {\n const audio = this.getAudioAsset(options.assetId).audio;\n await this.stop(options);\n audio.loop = true;\n return audio.play();\n }\n async stop(options) {\n const audio = this.getAudioAsset(options.assetId).audio;\n audio.pause();\n audio.loop = false;\n audio.currentTime = 0;\n }\n async unload(options) {\n await this.stop(options);\n NativeAudioWeb.AUDIO_ASSET_BY_ASSET_ID.delete(options.assetId);\n }\n async setVolume(options) {\n if (typeof (options === null || options === void 0 ? void 0 : options.volume) !== 'number') {\n throw 'no volume provided';\n }\n const audio = this.getAudioAsset(options.assetId).audio;\n audio.volume = options.volume;\n }\n async setRate(options) {\n if (typeof (options === null || options === void 0 ? void 0 : options.rate) !== 'number') {\n throw 'no rate provided';\n }\n const audio = this.getAudioAsset(options.assetId).audio;\n audio.playbackRate = options.rate;\n }\n async isPlaying(options) {\n const audio = this.getAudioAsset(options.assetId).audio;\n return { isPlaying: !audio.paused };\n }\n getAudioAsset(assetId) {\n this.checkAssetId(assetId);\n if (!NativeAudioWeb.AUDIO_ASSET_BY_ASSET_ID.has(assetId)) {\n throw `no asset for assetId \"${assetId}\" available. Call preload first!`;\n }\n return NativeAudioWeb.AUDIO_ASSET_BY_ASSET_ID.get(assetId);\n }\n checkAssetId(assetId) {\n if (typeof assetId !== 'string') {\n throw 'assetId must be a string';\n }\n if (!(assetId === null || assetId === void 0 ? void 0 : assetId.length)) {\n throw 'no assetId provided';\n }\n }\n}\nNativeAudioWeb.FILE_LOCATION = '';\nNativeAudioWeb.AUDIO_ASSET_BY_ASSET_ID = new Map();\nconst NativeAudio = new NativeAudioWeb();\nexport { NativeAudio };\n//# sourceMappingURL=web.js.map"],"names":["NativeAudio","registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAACA,aAAW,GAAGC,mBAAc,CAAC,aAAa,EAAE;AAClD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;AAClE,CAAC;;ACHM,MAAM,UAAU,CAAC;AACxB,IAAI,WAAW,CAAC,KAAK,EAAE;AACvB,QAAQ,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;AAC3B,KAAK;AACL;;ACFO,MAAM,cAAc,SAASC,cAAS,CAAC;AAC9C,IAAI,WAAW,GAAG;AAClB,QAAQ,KAAK,CAAC;AACd,YAAY,IAAI,EAAE,aAAa;AAC/B,YAAY,SAAS,EAAE,CAAC,KAAK,CAAC;AAC9B,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,MAAM,MAAM,CAAC,OAAO,EAAE;AAC1B,QAAQ,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC;AAChE,QAAQ,IAAI,KAAK,CAAC,MAAM,EAAE;AAC1B,YAAY,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC;AAChC,SAAS;AACT,KAAK;AACL,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE;AACzB,QAAQ,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC;AAChE,QAAQ,OAAO,KAAK,CAAC,KAAK,EAAE,CAAC;AAC7B,KAAK;AACL,IAAI,MAAM,cAAc,CAAC,OAAO,EAAE;AAClC,Q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AAO,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE;AACjF,YAAY,MAAM,qBAAqB,CAAC;AACxC,SAAS;AACT,KAAK;AACL,CAAC;AACD,cAAc,CAAC,aAAa,GAAG,EAAE,CAAC;AAClC,cAAc,CAAC,uBAAuB,GAAG,IAAI,GAAG,EAAE,CAAC;AACnD,MAAM,WAAW,GAAG,IAAI,cAAc,EAAE;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/audio-asset.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from \"@capacitor/core\";\nconst NativeAudio = registerPlugin(\"NativeAudio\", {\n web: () => import(\"./web\").then((m) => new m.NativeAudioWeb()),\n});\nexport * from \"./definitions\";\nexport { NativeAudio };\n//# sourceMappingURL=index.js.map","export class AudioAsset {\n constructor(audio) {\n this.audio = audio;\n }\n}\n//# sourceMappingURL=audio-asset.js.map","import { WebPlugin } from \"@capacitor/core\";\nimport { AudioAsset } from \"./audio-asset\";\nexport class NativeAudioWeb extends WebPlugin {\n constructor() {\n super({\n name: \"NativeAudio\",\n platforms: [\"web\"],\n });\n }\n async resume(options) {\n const audio = this.getAudioAsset(options.assetId).audio;\n if (audio.paused) {\n return audio.play();\n }\n }\n async pause(options) {\n const audio = this.getAudioAsset(options.assetId).audio;\n return audio.pause();\n }\n async getCurrentTime(options) {\n const audio = this.getAudioAsset(options.assetId).audio;\n return { currentTime: audio.currentTime };\n }\n async getDuration(options) {\n const audio = this.getAudioAsset(options.assetId).audio;\n if (Number.isNaN(audio.duration)) {\n throw \"no duration available\";\n }\n if (!Number.isFinite(audio.duration)) {\n throw \"duration not available => media resource is streaming\";\n }\n return { duration: audio.duration };\n }\n async configure(options) {\n throw `configure is not supported for web: ${JSON.stringify(options)}`;\n }\n async preload(options) {\n var _a;\n if (NativeAudioWeb.AUDIO_ASSET_BY_ASSET_ID.has(options.assetId)) {\n throw \"AssetId already exists. Unload first if like to change!\";\n }\n if (!((_a = options.assetPath) === null || _a === void 0 ? void 0 : _a.length)) {\n throw \"no assetPath provided\";\n }\n if (!options.isUrl &&\n !new RegExp(\"^/?\" + NativeAudioWeb.FILE_LOCATION).test(options.assetPath)) {\n const slashPrefix = options.assetPath.startsWith(\"/\") ? \"\" : \"/\";\n options.assetPath = `${NativeAudioWeb.FILE_LOCATION}${slashPrefix}${options.assetPath}`;\n }\n const audio = new Audio(options.assetPath);\n audio.autoplay = false;\n audio.loop = false;\n audio.preload = \"auto\";\n if (options.volume) {\n audio.volume = options.volume;\n }\n NativeAudioWeb.AUDIO_ASSET_BY_ASSET_ID.set(options.assetId, new AudioAsset(audio));\n }\n async play(options) {\n var _a;\n const audio = this.getAudioAsset(options.assetId).audio;\n await this.stop(options);\n audio.loop = false;\n audio.currentTime = (_a = options.time) !== null && _a !== void 0 ? _a : 0;\n return audio.play();\n }\n async loop(options) {\n const audio = this.getAudioAsset(options.assetId).audio;\n await this.stop(options);\n audio.loop = true;\n return audio.play();\n }\n async stop(options) {\n const audio = this.getAudioAsset(options.assetId).audio;\n audio.pause();\n audio.loop = false;\n audio.currentTime = 0;\n }\n async unload(options) {\n await this.stop(options);\n NativeAudioWeb.AUDIO_ASSET_BY_ASSET_ID.delete(options.assetId);\n }\n async setVolume(options) {\n if (typeof (options === null || options === void 0 ? void 0 : options.volume) !== \"number\") {\n throw \"no volume provided\";\n }\n const audio = this.getAudioAsset(options.assetId).audio;\n audio.volume = options.volume;\n }\n async setRate(options) {\n if (typeof (options === null || options === void 0 ? void 0 : options.rate) !== \"number\") {\n throw \"no rate provided\";\n }\n const audio = this.getAudioAsset(options.assetId).audio;\n audio.playbackRate = options.rate;\n }\n async isPlaying(options) {\n const audio = this.getAudioAsset(options.assetId).audio;\n return { isPlaying: !audio.paused };\n }\n getAudioAsset(assetId) {\n this.checkAssetId(assetId);\n if (!NativeAudioWeb.AUDIO_ASSET_BY_ASSET_ID.has(assetId)) {\n throw `no asset for assetId \"${assetId}\" available. Call preload first!`;\n }\n return NativeAudioWeb.AUDIO_ASSET_BY_ASSET_ID.get(assetId);\n }\n checkAssetId(assetId) {\n if (typeof assetId !== \"string\") {\n throw \"assetId must be a string\";\n }\n if (!(assetId === null || assetId === void 0 ? void 0 : assetId.length)) {\n throw \"no assetId provided\";\n }\n }\n}\nNativeAudioWeb.FILE_LOCATION = \"\";\nNativeAudioWeb.AUDIO_ASSET_BY_ASSET_ID = new Map();\nconst NativeAudio = new NativeAudioWeb();\nexport { NativeAudio };\n//# sourceMappingURL=web.js.map"],"names":["NativeAudio","registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAACA,aAAW,GAAGC,mBAAc,CAAC,aAAa,EAAE;AAClD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;AAClE,CAAC;;ACHM,MAAM,UAAU,CAAC;AACxB,IAAI,WAAW,CAAC,KAAK,EAAE;AACvB,QAAQ,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;AAC3B,KAAK;AACL;;ACFO,MAAM,cAAc,SAASC,cAAS,CAAC;AAC9C,IAAI,WAAW,GAAG;AAClB,QAAQ,KAAK,CAAC;AACd,YAAY,IAAI,EAAE,aAAa;AAC/B,YAAY,SAAS,EAAE,CAAC,KAAK,CAAC;AAC9B,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,MAAM,MAAM,CAAC,OAAO,EAAE;AAC1B,QAAQ,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC;AAChE,QAAQ,IAAI,KAAK,CAAC,MAAM,EAAE;AAC1B,YAAY,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC;AAChC,SAAS;AACT,KAAK;AACL,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE;AACzB,QAAQ,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,C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CAAC,OAAO,EAAE;AAC1B,QAAQ,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;AACzC,YAAY,MAAM,0BAA0B,CAAC;AAC7C,SAAS;AACT,QAAQ,IAAI,EAAE,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE;AACjF,YAAY,MAAM,qBAAqB,CAAC;AACxC,SAAS;AACT,KAAK;AACL,CAAC;AACD,cAAc,CAAC,aAAa,GAAG,EAAE,CAAC;AAClC,cAAc,CAAC,uBAAuB,GAAG,IAAI,GAAG,EAAE,CAAC;AACnD,MAAM,WAAW,GAAG,IAAI,cAAc,EAAE;;;;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var capacitorApp = (function (exports, core) {
2
2
  'use strict';
3
3
 
4
- const NativeAudio$1 = core.registerPlugin('NativeAudio', {
4
+ const NativeAudio$1 = core.registerPlugin("NativeAudio", {
5
5
  web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.NativeAudioWeb()),
6
6
  });
7
7
 
@@ -14,8 +14,8 @@ var capacitorApp = (function (exports, core) {
14
14
  class NativeAudioWeb extends core.WebPlugin {
15
15
  constructor() {
16
16
  super({
17
- name: 'NativeAudio',
18
- platforms: ['web'],
17
+ name: "NativeAudio",
18
+ platforms: ["web"],
19
19
  });
20
20
  }
21
21
  async resume(options) {
@@ -35,10 +35,10 @@ var capacitorApp = (function (exports, core) {
35
35
  async getDuration(options) {
36
36
  const audio = this.getAudioAsset(options.assetId).audio;
37
37
  if (Number.isNaN(audio.duration)) {
38
- throw 'no duration available';
38
+ throw "no duration available";
39
39
  }
40
40
  if (!Number.isFinite(audio.duration)) {
41
- throw 'duration not available => media resource is streaming';
41
+ throw "duration not available => media resource is streaming";
42
42
  }
43
43
  return { duration: audio.duration };
44
44
  }
@@ -48,19 +48,20 @@ var capacitorApp = (function (exports, core) {
48
48
  async preload(options) {
49
49
  var _a;
50
50
  if (NativeAudioWeb.AUDIO_ASSET_BY_ASSET_ID.has(options.assetId)) {
51
- throw 'AssetId already exists. Unload first if like to change!';
51
+ throw "AssetId already exists. Unload first if like to change!";
52
52
  }
53
53
  if (!((_a = options.assetPath) === null || _a === void 0 ? void 0 : _a.length)) {
54
- throw 'no assetPath provided';
54
+ throw "no assetPath provided";
55
55
  }
56
- if (!options.isUrl && !new RegExp('^/?' + NativeAudioWeb.FILE_LOCATION).test(options.assetPath)) {
57
- const slashPrefix = options.assetPath.startsWith('/') ? '' : '/';
56
+ if (!options.isUrl &&
57
+ !new RegExp("^/?" + NativeAudioWeb.FILE_LOCATION).test(options.assetPath)) {
58
+ const slashPrefix = options.assetPath.startsWith("/") ? "" : "/";
58
59
  options.assetPath = `${NativeAudioWeb.FILE_LOCATION}${slashPrefix}${options.assetPath}`;
59
60
  }
60
61
  const audio = new Audio(options.assetPath);
61
62
  audio.autoplay = false;
62
63
  audio.loop = false;
63
- audio.preload = 'auto';
64
+ audio.preload = "auto";
64
65
  if (options.volume) {
65
66
  audio.volume = options.volume;
66
67
  }
@@ -91,15 +92,15 @@ var capacitorApp = (function (exports, core) {
91
92
  NativeAudioWeb.AUDIO_ASSET_BY_ASSET_ID.delete(options.assetId);
92
93
  }
93
94
  async setVolume(options) {
94
- if (typeof (options === null || options === void 0 ? void 0 : options.volume) !== 'number') {
95
- throw 'no volume provided';
95
+ if (typeof (options === null || options === void 0 ? void 0 : options.volume) !== "number") {
96
+ throw "no volume provided";
96
97
  }
97
98
  const audio = this.getAudioAsset(options.assetId).audio;
98
99
  audio.volume = options.volume;
99
100
  }
100
101
  async setRate(options) {
101
- if (typeof (options === null || options === void 0 ? void 0 : options.rate) !== 'number') {
102
- throw 'no rate provided';
102
+ if (typeof (options === null || options === void 0 ? void 0 : options.rate) !== "number") {
103
+ throw "no rate provided";
103
104
  }
104
105
  const audio = this.getAudioAsset(options.assetId).audio;
105
106
  audio.playbackRate = options.rate;
@@ -116,15 +117,15 @@ var capacitorApp = (function (exports, core) {
116
117
  return NativeAudioWeb.AUDIO_ASSET_BY_ASSET_ID.get(assetId);
117
118
  }
118
119
  checkAssetId(assetId) {
119
- if (typeof assetId !== 'string') {
120
- throw 'assetId must be a string';
120
+ if (typeof assetId !== "string") {
121
+ throw "assetId must be a string";
121
122
  }
122
123
  if (!(assetId === null || assetId === void 0 ? void 0 : assetId.length)) {
123
- throw 'no assetId provided';
124
+ throw "no assetId provided";
124
125
  }
125
126
  }
126
127
  }
127
- NativeAudioWeb.FILE_LOCATION = '';
128
+ NativeAudioWeb.FILE_LOCATION = "";
128
129
  NativeAudioWeb.AUDIO_ASSET_BY_ASSET_ID = new Map();
129
130
  const NativeAudio = new NativeAudioWeb();
130
131