@capgo/native-audio 8.3.18 → 8.4.1

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
@@ -249,6 +249,10 @@ The media control buttons automatically handle:
249
249
  - **Rewind 15s** (Android only) - Skips backward 15 seconds
250
250
  - **Forward 15s** (Android only) - Skips forward 15 seconds
251
251
 
252
+ If you need to keep your app UI synchronized with Android notification or lock-screen controls,
253
+ listen for the `playbackState` event. It emits the `assetId`, resolved state, reason, and the latest
254
+ position/duration snapshot after remote transport actions.
255
+
252
256
  **Android Notification Controls:**
253
257
  On Android, the notification displays three action buttons in this order:
254
258
  1. ⏪ **Rewind 15s** - Skip backward 15 seconds
@@ -423,15 +427,15 @@ await NativeAudio.stop({ assetId });
423
427
 
424
428
  ## Example app
425
429
 
426
- This repository now ships with an interactive Capacitor project under `example/` that exercises the main APIs on web, iOS, and Android shells.
430
+ This repository now ships with an interactive Capacitor project under `example-app/` that exercises the main APIs on web, iOS, and Android shells.
427
431
 
428
432
  ```bash
429
- cd example
430
- npm install
431
- npm run dev # start the web playground
432
- npm run sync # optional: generate iOS/Android platforms
433
- npm run ios # open the iOS shell app
434
- npm run android # open the Android shell app
433
+ cd example-app
434
+ bun install
435
+ bun run dev # start the web playground
436
+ bun run sync # optional: generate iOS/Android platforms
437
+ bun run ios # open the iOS shell app
438
+ bun run android # open the Android shell app
435
439
  ```
436
440
 
437
441
  The UI demonstrates local asset preloading, remote streaming, playback controls, looping, live position updates, and cache clearing for remote audio.
@@ -921,6 +925,28 @@ return {@link CurrentTimeEvent}
921
925
  --------------------
922
926
 
923
927
 
928
+ ### addListener('playbackState', ...)
929
+
930
+ ```typescript
931
+ addListener(eventName: 'playbackState', listenerFunc: PlaybackStateListener) => Promise<PluginListenerHandle>
932
+ ```
933
+
934
+ Listen for playback state changes, including notification and lock-screen transport controls.
935
+ Emitted by Android and iOS. The current Web implementation does not emit this event.
936
+
937
+ | Param | Type |
938
+ | ------------------ | ----------------------------------------------------------------------- |
939
+ | **`eventName`** | <code>'playbackState'</code> |
940
+ | **`listenerFunc`** | <code><a href="#playbackstatelistener">PlaybackStateListener</a></code> |
941
+
942
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
943
+
944
+ **Since:** 8.3.15
945
+ return {@link PlaybackStateEvent}
946
+
947
+ --------------------
948
+
949
+
924
950
  ### clearCache()
925
951
 
926
952
  ```typescript
@@ -1139,6 +1165,18 @@ behavior details about audio mixing on iOS.
1139
1165
  | **`assetId`** | <code>string</code> | Asset Id of the audio | 6.5.0 |
1140
1166
 
1141
1167
 
1168
+ #### PlaybackStateEvent
1169
+
1170
+ | Prop | Type | Description |
1171
+ | ----------------- | ----------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
1172
+ | **`assetId`** | <code>string</code> | Asset Id of the audio |
1173
+ | **`state`** | <code><a href="#playbackstatevalue">PlaybackStateValue</a></code> | Resolved playback state after a local or remote transport action. |
1174
+ | **`reason`** | <code>string</code> | Reason for the state change, for example `play`, `pause`, `remotePlay`, or `complete`. |
1175
+ | **`isPlaying`** | <code>boolean</code> | Whether the asset is currently playing. |
1176
+ | **`currentTime`** | <code>number</code> | Current playback position in seconds when available. |
1177
+ | **`duration`** | <code>number</code> | Total playback duration in seconds when available. |
1178
+
1179
+
1142
1180
  ### Type Aliases
1143
1181
 
1144
1182
 
@@ -1158,6 +1196,16 @@ Construct a type with a set of properties K of type T
1158
1196
 
1159
1197
  <code>(state: <a href="#currenttimeevent">CurrentTimeEvent</a>): void</code>
1160
1198
 
1199
+
1200
+ #### PlaybackStateListener
1201
+
1202
+ <code>(state: <a href="#playbackstateevent">PlaybackStateEvent</a>): void</code>
1203
+
1204
+
1205
+ #### PlaybackStateValue
1206
+
1207
+ <code>'playing' | 'paused' | 'stopped'</code>
1208
+
1161
1209
  </docgen-api>
1162
1210
 
1163
1211
  ## Development and Testing
@@ -1165,15 +1213,17 @@ Construct a type with a set of properties K of type T
1165
1213
  ### Building
1166
1214
 
1167
1215
  ```bash
1168
- npm run build
1216
+ bun run build
1169
1217
  ```
1170
1218
 
1171
1219
  ### Testing
1172
1220
 
1173
- This plugin includes a comprehensive test suite for iOS:
1221
+ This plugin includes native unit coverage plus Maestro smoke tests for the example app on iOS and Android:
1174
1222
 
1175
- 1. Open the iOS project in Xcode: `npx cap open ios`
1176
- 2. Navigate to the `PluginTests` directory
1177
- 3. Run tests using Product > Test (⌘+U)
1223
+ 1. Run plugin verification with `bun run verify`
1224
+ 2. Build and sync the example app from `example-app/`
1225
+ 3. With a booted device and the shell app installed, run the Android smoke flow with `bun run test:e2e:android`
1226
+ 4. With a booted simulator and the shell app installed, run the iOS smoke flow with `bun run test:e2e:ios`
1227
+ 5. For native unit tests in Xcode, open the example app iOS project with `cd example-app && bunx cap open ios` and run Product > Test (⌘+U)
1178
1228
 
1179
- The tests cover core functionality including audio asset initialization, playback, volume control, fade effects, and more. See the [test documentation](ios/PluginTests/README.md) for more details.
1229
+ The tests cover core functionality including audio asset initialization, playback, volume control, fade effects, and smoke-tested example app playback flows. See the [test documentation](ios/Tests/README.md) for more details.
@@ -80,7 +80,7 @@ dependencies {
80
80
 
81
81
  implementation 'androidx.media3:media3-session:1.10.0'
82
82
  implementation 'androidx.media3:media3-transformer:1.9.2'
83
- implementation 'androidx.media3:media3-ui:1.9.2'
83
+ implementation 'androidx.media3:media3-ui:1.10.0'
84
84
  implementation 'androidx.media3:media3-database:1.10.0'
85
85
  implementation 'androidx.media3:media3-common:1.10.0'
86
86
  // Media notification support