@capgo/native-audio 8.2.12 → 8.2.13
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 +147 -34
- package/android/src/main/java/ee/forgr/audio/AudioAsset.java +352 -74
- package/android/src/main/java/ee/forgr/audio/AudioDispatcher.java +24 -3
- package/android/src/main/java/ee/forgr/audio/Constant.java +9 -1
- package/android/src/main/java/ee/forgr/audio/Logger.java +55 -0
- package/android/src/main/java/ee/forgr/audio/NativeAudio.java +336 -57
- package/android/src/main/java/ee/forgr/audio/RemoteAudioAsset.java +307 -98
- package/android/src/main/java/ee/forgr/audio/StreamAudioAsset.java +285 -96
- package/dist/docs.json +307 -41
- package/dist/esm/definitions.d.ts +116 -38
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +52 -41
- package/dist/esm/web.js +386 -41
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +386 -41
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +386 -41
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/NativeAudioPlugin/AudioAsset+Fade.swift +104 -0
- package/ios/Sources/NativeAudioPlugin/AudioAsset.swift +168 -324
- package/ios/Sources/NativeAudioPlugin/Constant.swift +17 -4
- package/ios/Sources/NativeAudioPlugin/Logger.swift +43 -0
- package/ios/Sources/NativeAudioPlugin/Plugin.swift +176 -87
- package/ios/Sources/NativeAudioPlugin/RemoteAudioAsset+Fade.swift +110 -0
- package/ios/Sources/NativeAudioPlugin/RemoteAudioAsset.swift +117 -273
- package/ios/Tests/NativeAudioPluginTests/PluginTests.swift +47 -72
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -158,7 +158,7 @@ npx cap sync
|
|
|
158
158
|
## Supported methods
|
|
159
159
|
|
|
160
160
|
| Name | Android | iOS | Web |
|
|
161
|
-
|
|
161
|
+
|:---------------| :------ | :-- | :-- |
|
|
162
162
|
| configure | ✅ | ✅ | ❌ |
|
|
163
163
|
| preload | ✅ | ✅ | ✅ |
|
|
164
164
|
| play | ✅ | ✅ | ✅ |
|
|
@@ -169,6 +169,7 @@ npx cap sync
|
|
|
169
169
|
| unload | ✅ | ✅ | ✅ |
|
|
170
170
|
| setVolume | ✅ | ✅ | ✅ |
|
|
171
171
|
| getDuration | ✅ | ✅ | ✅ |
|
|
172
|
+
| setCurrentTime | ✅ | ✅ | ✅ |
|
|
172
173
|
| getCurrentTime | ✅ | ✅ | ✅ |
|
|
173
174
|
| isPlaying | ✅ | ✅ | ✅ |
|
|
174
175
|
|
|
@@ -448,11 +449,24 @@ NativeAudio.preload({
|
|
|
448
449
|
* This method will play the loaded audio file if present in the memory.
|
|
449
450
|
* @param assetId - identifier of the asset
|
|
450
451
|
* @param time - (optional) play with seek. example: 6.0 - start playing track from 6 sec
|
|
452
|
+
* @param delay - (optional) delay the audio. default is 0s
|
|
453
|
+
* @param fadeIn - (optional) whether fade in the audio. default is false
|
|
454
|
+
* @param fadeOut - (optional) whether fade out the audio. default is false
|
|
455
|
+
* @param fadeInDuration - (optional) fade in duration in seconds. only used if fadeIn is true. default is 1s
|
|
456
|
+
* @param fadeOutDuration - (optional) fade out duration in seconds. only used if fadeOut is true. default is 1s
|
|
457
|
+
* @param fadeOutStartTime - (optional) time in seconds from the start of the audio to start fading out. only used if fadeOut is true. default is fadeOutDuration before end of audio.
|
|
451
458
|
* @returns void
|
|
452
459
|
*/
|
|
453
460
|
NativeAudio.play({
|
|
454
461
|
assetId: 'fire',
|
|
455
462
|
// time: 6.0 - seek time
|
|
463
|
+
// volume: 0.4,
|
|
464
|
+
// delay: 1.0,
|
|
465
|
+
// fadeIn: true,
|
|
466
|
+
// fadeOut: true,
|
|
467
|
+
// fadeInDuration: 2,
|
|
468
|
+
// fadeOutDuration: 2
|
|
469
|
+
// fadeOutStartTime: 2
|
|
456
470
|
});
|
|
457
471
|
|
|
458
472
|
/**
|
|
@@ -468,10 +482,14 @@ NativeAudio.loop({
|
|
|
468
482
|
/**
|
|
469
483
|
* This method will stop the audio file if it's currently playing.
|
|
470
484
|
* @param assetId - identifier of the asset
|
|
485
|
+
* @param fadeOut - (optional) whether fade out the audio before stopping. default is false
|
|
486
|
+
* @param fadeOutDuration - (optional) fade out duration in seconds. default is 1s
|
|
471
487
|
* @returns void
|
|
472
488
|
*/
|
|
473
489
|
NativeAudio.stop({
|
|
474
490
|
assetId: 'fire',
|
|
491
|
+
// fadeOut: true,
|
|
492
|
+
// fadeOutDuration: 2
|
|
475
493
|
});
|
|
476
494
|
|
|
477
495
|
/**
|
|
@@ -487,11 +505,13 @@ NativeAudio.unload({
|
|
|
487
505
|
* This method will set the new volume for a audio file.
|
|
488
506
|
* @param assetId - identifier of the asset
|
|
489
507
|
* volume - numerical value of the volume between 0.1 - 1.0 default 1.0
|
|
508
|
+
* duration - time over which to fade to the target volume, in seconds. default is 0s (immediate)
|
|
490
509
|
* @returns void
|
|
491
510
|
*/
|
|
492
511
|
NativeAudio.setVolume({
|
|
493
512
|
assetId: 'fire',
|
|
494
513
|
volume: 0.4,
|
|
514
|
+
// duration: 2
|
|
495
515
|
});
|
|
496
516
|
|
|
497
517
|
/**
|
|
@@ -511,11 +531,21 @@ NativeAudio.getDuration({
|
|
|
511
531
|
*/
|
|
512
532
|
NativeAudio.getCurrentTime({
|
|
513
533
|
assetId: 'fire'
|
|
514
|
-
})
|
|
534
|
+
})
|
|
515
535
|
.then(result => {
|
|
516
536
|
console.log(result.currentTime);
|
|
517
537
|
})
|
|
518
538
|
|
|
539
|
+
/**
|
|
540
|
+
* this method will set the current time of a playing audio file.
|
|
541
|
+
* @param assetId - identifier of the asset
|
|
542
|
+
* time - time to set the audio, in seconds
|
|
543
|
+
*/
|
|
544
|
+
NativeAudio.setCurrentTime({
|
|
545
|
+
assetId: 'fire',
|
|
546
|
+
time: 6.0
|
|
547
|
+
})
|
|
548
|
+
|
|
519
549
|
/**
|
|
520
550
|
* This method will return false if audio is paused or not loaded.
|
|
521
551
|
* @param assetId - identifier of the asset
|
|
@@ -631,14 +661,14 @@ Check if an audio file is preloaded
|
|
|
631
661
|
### play(...)
|
|
632
662
|
|
|
633
663
|
```typescript
|
|
634
|
-
play(options:
|
|
664
|
+
play(options: AssetPlayOptions) => Promise<void>
|
|
635
665
|
```
|
|
636
666
|
|
|
637
667
|
Play an audio file
|
|
638
668
|
|
|
639
|
-
| Param | Type
|
|
640
|
-
| ------------- |
|
|
641
|
-
| **`options`** | <code>
|
|
669
|
+
| Param | Type |
|
|
670
|
+
| ------------- | ------------------------------------------------------------- |
|
|
671
|
+
| **`options`** | <code><a href="#assetplayoptions">AssetPlayOptions</a></code> |
|
|
642
672
|
|
|
643
673
|
**Since:** 5.0.0
|
|
644
674
|
|
|
@@ -648,14 +678,14 @@ Play an audio file
|
|
|
648
678
|
### pause(...)
|
|
649
679
|
|
|
650
680
|
```typescript
|
|
651
|
-
pause(options:
|
|
681
|
+
pause(options: AssetPauseOptions) => Promise<void>
|
|
652
682
|
```
|
|
653
683
|
|
|
654
684
|
Pause an audio file
|
|
655
685
|
|
|
656
|
-
| Param | Type
|
|
657
|
-
| ------------- |
|
|
658
|
-
| **`options`** | <code><a href="#
|
|
686
|
+
| Param | Type |
|
|
687
|
+
| ------------- | --------------------------------------------------------------- |
|
|
688
|
+
| **`options`** | <code><a href="#assetpauseoptions">AssetPauseOptions</a></code> |
|
|
659
689
|
|
|
660
690
|
**Since:** 5.0.0
|
|
661
691
|
|
|
@@ -665,14 +695,14 @@ Pause an audio file
|
|
|
665
695
|
### resume(...)
|
|
666
696
|
|
|
667
697
|
```typescript
|
|
668
|
-
resume(options:
|
|
698
|
+
resume(options: AssetResumeOptions) => Promise<void>
|
|
669
699
|
```
|
|
670
700
|
|
|
671
701
|
Resume an audio file
|
|
672
702
|
|
|
673
|
-
| Param | Type
|
|
674
|
-
| ------------- |
|
|
675
|
-
| **`options`** | <code><a href="#
|
|
703
|
+
| Param | Type |
|
|
704
|
+
| ------------- | ----------------------------------------------------------------- |
|
|
705
|
+
| **`options`** | <code><a href="#assetresumeoptions">AssetResumeOptions</a></code> |
|
|
676
706
|
|
|
677
707
|
**Since:** 5.0.0
|
|
678
708
|
|
|
@@ -699,14 +729,14 @@ Stop an audio file
|
|
|
699
729
|
### stop(...)
|
|
700
730
|
|
|
701
731
|
```typescript
|
|
702
|
-
stop(options:
|
|
732
|
+
stop(options: AssetStopOptions) => Promise<void>
|
|
703
733
|
```
|
|
704
734
|
|
|
705
735
|
Stop an audio file
|
|
706
736
|
|
|
707
|
-
| Param | Type
|
|
708
|
-
| ------------- |
|
|
709
|
-
| **`options`** | <code><a href="#
|
|
737
|
+
| Param | Type |
|
|
738
|
+
| ------------- | ------------------------------------------------------------- |
|
|
739
|
+
| **`options`** | <code><a href="#assetstopoptions">AssetStopOptions</a></code> |
|
|
710
740
|
|
|
711
741
|
**Since:** 5.0.0
|
|
712
742
|
|
|
@@ -733,14 +763,14 @@ Unload an audio file
|
|
|
733
763
|
### setVolume(...)
|
|
734
764
|
|
|
735
765
|
```typescript
|
|
736
|
-
setVolume(options:
|
|
766
|
+
setVolume(options: AssetVolume) => Promise<void>
|
|
737
767
|
```
|
|
738
768
|
|
|
739
769
|
Set the volume of an audio file
|
|
740
770
|
|
|
741
|
-
| Param | Type
|
|
742
|
-
| ------------- |
|
|
743
|
-
| **`options`** | <code>
|
|
771
|
+
| Param | Type |
|
|
772
|
+
| ------------- | --------------------------------------------------- |
|
|
773
|
+
| **`options`** | <code><a href="#assetvolume">AssetVolume</a></code> |
|
|
744
774
|
|
|
745
775
|
**Since:** 5.0.0
|
|
746
776
|
|
|
@@ -750,14 +780,14 @@ Set the volume of an audio file
|
|
|
750
780
|
### setRate(...)
|
|
751
781
|
|
|
752
782
|
```typescript
|
|
753
|
-
setRate(options:
|
|
783
|
+
setRate(options: AssetRate) => Promise<void>
|
|
754
784
|
```
|
|
755
785
|
|
|
756
786
|
Set the rate of an audio file
|
|
757
787
|
|
|
758
788
|
| Param | Type |
|
|
759
789
|
| ------------- | ----------------------------------------------- |
|
|
760
|
-
| **`options`** | <code>
|
|
790
|
+
| **`options`** | <code><a href="#assetrate">AssetRate</a></code> |
|
|
761
791
|
|
|
762
792
|
**Since:** 5.0.0
|
|
763
793
|
|
|
@@ -767,14 +797,14 @@ Set the rate of an audio file
|
|
|
767
797
|
### setCurrentTime(...)
|
|
768
798
|
|
|
769
799
|
```typescript
|
|
770
|
-
setCurrentTime(options:
|
|
800
|
+
setCurrentTime(options: AssetSetTime) => Promise<void>
|
|
771
801
|
```
|
|
772
802
|
|
|
773
803
|
Set the current time of an audio file
|
|
774
804
|
|
|
775
|
-
| Param | Type
|
|
776
|
-
| ------------- |
|
|
777
|
-
| **`options`** | <code>
|
|
805
|
+
| Param | Type |
|
|
806
|
+
| ------------- | ----------------------------------------------------- |
|
|
807
|
+
| **`options`** | <code><a href="#assetsettime">AssetSetTime</a></code> |
|
|
778
808
|
|
|
779
809
|
**Since:** 6.5.0
|
|
780
810
|
|
|
@@ -784,14 +814,14 @@ Set the current time of an audio file
|
|
|
784
814
|
### getCurrentTime(...)
|
|
785
815
|
|
|
786
816
|
```typescript
|
|
787
|
-
getCurrentTime(options:
|
|
817
|
+
getCurrentTime(options: Assets) => Promise<{ currentTime: number; }>
|
|
788
818
|
```
|
|
789
819
|
|
|
790
820
|
Get the current time of an audio file
|
|
791
821
|
|
|
792
|
-
| Param | Type
|
|
793
|
-
| ------------- |
|
|
794
|
-
| **`options`** | <code>
|
|
822
|
+
| Param | Type |
|
|
823
|
+
| ------------- | ----------------------------------------- |
|
|
824
|
+
| **`options`** | <code><a href="#assets">Assets</a></code> |
|
|
795
825
|
|
|
796
826
|
**Returns:** <code>Promise<{ currentTime: number; }></code>
|
|
797
827
|
|
|
@@ -806,7 +836,7 @@ Get the current time of an audio file
|
|
|
806
836
|
getDuration(options: Assets) => Promise<{ duration: number; }>
|
|
807
837
|
```
|
|
808
838
|
|
|
809
|
-
Get the duration of an audio file
|
|
839
|
+
Get the duration of an audio file in seconds
|
|
810
840
|
|
|
811
841
|
| Param | Type |
|
|
812
842
|
| ------------- | ----------------------------------------- |
|
|
@@ -894,6 +924,23 @@ Clear the audio cache for remote audio files
|
|
|
894
924
|
--------------------
|
|
895
925
|
|
|
896
926
|
|
|
927
|
+
### setDebugMode(...)
|
|
928
|
+
|
|
929
|
+
```typescript
|
|
930
|
+
setDebugMode(options: { enabled: boolean; }) => Promise<void>
|
|
931
|
+
```
|
|
932
|
+
|
|
933
|
+
Set debug mode logging
|
|
934
|
+
|
|
935
|
+
| Param | Type | Description |
|
|
936
|
+
| ------------- | ---------------------------------- | ----------------------------------------- |
|
|
937
|
+
| **`options`** | <code>{ enabled: boolean; }</code> | - Options to enable or disable debug mode |
|
|
938
|
+
|
|
939
|
+
**Since:** 6.5.0
|
|
940
|
+
|
|
941
|
+
--------------------
|
|
942
|
+
|
|
943
|
+
|
|
897
944
|
### getPluginVersion()
|
|
898
945
|
|
|
899
946
|
```typescript
|
|
@@ -929,7 +976,6 @@ Use this when you need to ensure compatibility with other audio plugins
|
|
|
929
976
|
|
|
930
977
|
| Prop | Type | Description | Default | Since |
|
|
931
978
|
| ------------------------ | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ----- |
|
|
932
|
-
| **`fade`** | <code>boolean</code> | Play the audio with Fade effect, only available for IOS | | |
|
|
933
979
|
| **`focus`** | <code>boolean</code> | focus the audio with Audio Focus | | |
|
|
934
980
|
| **`background`** | <code>boolean</code> | Play the audio in the background | | |
|
|
935
981
|
| **`ignoreSilent`** | <code>boolean</code> | Ignore silent mode, works only on iOS setting this will nuke other audio apps | | |
|
|
@@ -987,6 +1033,39 @@ behavior details about audio mixing on iOS.
|
|
|
987
1033
|
| **`headers`** | <code><a href="#record">Record</a><string, string></code> | Custom HTTP headers to include when fetching remote audio files. Only used when isUrl is true and assetPath is a remote URL (http/https). Example: { 'x-api-key': 'abc123', 'Authorization': 'Bearer token' } | | 7.10.0 |
|
|
988
1034
|
|
|
989
1035
|
|
|
1036
|
+
#### AssetPlayOptions
|
|
1037
|
+
|
|
1038
|
+
| Prop | Type | Description |
|
|
1039
|
+
| ---------------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1040
|
+
| **`assetId`** | <code>string</code> | Asset Id, unique identifier of the file |
|
|
1041
|
+
| **`time`** | <code>number</code> | Time to start playing the audio, in seconds |
|
|
1042
|
+
| **`delay`** | <code>number</code> | Delay to start playing the audio, in seconds |
|
|
1043
|
+
| **`volume`** | <code>number</code> | Volume of the audio, between 0.1 and 1.0 |
|
|
1044
|
+
| **`fadeIn`** | <code>boolean</code> | Whether to fade in the audio |
|
|
1045
|
+
| **`fadeOut`** | <code>boolean</code> | Whether to fade out the audio |
|
|
1046
|
+
| **`fadeInDuration`** | <code>number</code> | Fade in duration in seconds. Only used if fadeIn is true. Default is 1s. |
|
|
1047
|
+
| **`fadeOutDuration`** | <code>number</code> | Fade out duration in seconds. Only used if fadeOut is true. Default is 1s. |
|
|
1048
|
+
| **`fadeOutStartTime`** | <code>number</code> | Time in seconds from the start of the audio to start fading out. Only used if fadeOut is true. Default is fadeOutDuration before end of audio. |
|
|
1049
|
+
|
|
1050
|
+
|
|
1051
|
+
#### AssetPauseOptions
|
|
1052
|
+
|
|
1053
|
+
| Prop | Type | Description |
|
|
1054
|
+
| --------------------- | -------------------- | -------------------------------------------- |
|
|
1055
|
+
| **`assetId`** | <code>string</code> | Asset Id, unique identifier of the file |
|
|
1056
|
+
| **`fadeOut`** | <code>boolean</code> | Whether to fade out the audio before pausing |
|
|
1057
|
+
| **`fadeOutDuration`** | <code>number</code> | Fade out duration in seconds. Default is 1s. |
|
|
1058
|
+
|
|
1059
|
+
|
|
1060
|
+
#### AssetResumeOptions
|
|
1061
|
+
|
|
1062
|
+
| Prop | Type | Description |
|
|
1063
|
+
| -------------------- | -------------------- | ------------------------------------------- |
|
|
1064
|
+
| **`assetId`** | <code>string</code> | Asset Id, unique identifier of the file |
|
|
1065
|
+
| **`fadeIn`** | <code>boolean</code> | Whether to fade in the audio during resume |
|
|
1066
|
+
| **`fadeInDuration`** | <code>number</code> | Fade in duration in seconds. Default is 1s. |
|
|
1067
|
+
|
|
1068
|
+
|
|
990
1069
|
#### Assets
|
|
991
1070
|
|
|
992
1071
|
| Prop | Type | Description |
|
|
@@ -994,6 +1073,40 @@ behavior details about audio mixing on iOS.
|
|
|
994
1073
|
| **`assetId`** | <code>string</code> | Asset Id, unique identifier of the file |
|
|
995
1074
|
|
|
996
1075
|
|
|
1076
|
+
#### AssetStopOptions
|
|
1077
|
+
|
|
1078
|
+
| Prop | Type | Description |
|
|
1079
|
+
| --------------------- | -------------------- | --------------------------------------------- |
|
|
1080
|
+
| **`assetId`** | <code>string</code> | Asset Id, unique identifier of the file |
|
|
1081
|
+
| **`fadeOut`** | <code>boolean</code> | Whether to fade out the audio before stopping |
|
|
1082
|
+
| **`fadeOutDuration`** | <code>number</code> | Fade out duration in seconds. Default is 1s. |
|
|
1083
|
+
|
|
1084
|
+
|
|
1085
|
+
#### AssetVolume
|
|
1086
|
+
|
|
1087
|
+
| Prop | Type | Description |
|
|
1088
|
+
| -------------- | ------------------- | ------------------------------------------------------------------------------------ |
|
|
1089
|
+
| **`assetId`** | <code>string</code> | Asset Id, unique identifier of the file |
|
|
1090
|
+
| **`volume`** | <code>number</code> | Volume of the audio, between 0.1 and 1.0 |
|
|
1091
|
+
| **`duration`** | <code>number</code> | Time over which to fade to the target volume, in seconds. Default is 0s (immediate). |
|
|
1092
|
+
|
|
1093
|
+
|
|
1094
|
+
#### AssetRate
|
|
1095
|
+
|
|
1096
|
+
| Prop | Type | Description |
|
|
1097
|
+
| ------------- | ------------------- | --------------------------------------- |
|
|
1098
|
+
| **`assetId`** | <code>string</code> | Asset Id, unique identifier of the file |
|
|
1099
|
+
| **`rate`** | <code>number</code> | Rate of the audio, between 0.1 and 1.0 |
|
|
1100
|
+
|
|
1101
|
+
|
|
1102
|
+
#### AssetSetTime
|
|
1103
|
+
|
|
1104
|
+
| Prop | Type | Description |
|
|
1105
|
+
| ------------- | ------------------- | --------------------------------------- |
|
|
1106
|
+
| **`assetId`** | <code>string</code> | Asset Id, unique identifier of the file |
|
|
1107
|
+
| **`time`** | <code>number</code> | Time to set the audio, in seconds |
|
|
1108
|
+
|
|
1109
|
+
|
|
997
1110
|
#### PluginListenerHandle
|
|
998
1111
|
|
|
999
1112
|
| Prop | Type |
|