@simba-dev/react-native-media-player 3.1.0 → 3.2.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/CHANGELOG.md CHANGED
@@ -1,4 +1,105 @@
1
1
 
2
+ ## [3.2.0] - 2026-11-03
3
+
4
+ ### Fixed
5
+
6
+ - **Pressing HOME opened no Picture-in-Picture window at all.** The BUTTON path worked and was
7
+ proven on emulator-5554 (API 37): the app unmounted its chrome in React, waited one animation
8
+ frame, and then asked for the window. The HOME path did not — pressing HOME opened no PiP
9
+ window, and on return the screen was black and chromeless with the consumer's store stuck at
10
+ `pipActive=true` / `pipEntryRequested=true`.
11
+
12
+ The cause was measured, not guessed. `Activity.onUserLeaveHint()` fired and the JS handler ran
13
+ immediately, but the effect that would have driven the entry ran **5.7 s late** and the
14
+ `requestAnimationFrame` **never fired**. React Native pauses the React scheduler with the
15
+ Activity, so a React commit cannot land and there is no frame clock once the Activity is
16
+ backgrounded. The entry therefore has to be **native**, inside `onUserLeaveHint()`, before
17
+ `onPause`.
18
+
19
+ The library now performs the HOME-path entry itself:
20
+
21
+ - the consumer's chrome is hidden with a **native View-system mutation**
22
+ (`visibility = View.GONE`), which lands without a React commit and without a frame clock;
23
+ - the PiP parameters are built **after** the hide, by the same builder the JS path uses;
24
+ - the chrome is restored when Picture-in-Picture ends, and immediately if the OS refuses the
25
+ entry.
26
+
27
+ **Action required:** your Activity has to hand over the Activity.
28
+
29
+ ```kotlin
30
+ // android/app/src/main/java/.../MainActivity.kt
31
+ override fun onUserLeaveHint() {
32
+ super.onUserLeaveHint()
33
+ com.simba.player.mpv.MpvBridgeModule.notifyUserLeaveHint(this)
34
+ }
35
+ ```
36
+
37
+ If your app draws its own chrome over the picture, give that view a `nativeID` and name it in
38
+ the config — the library hides that view, and nothing else:
39
+
40
+ ```tsx
41
+ // the chrome root
42
+ <View nativeID="player-chrome" style={styles.chrome}>{/* your controls */}</View>
43
+ ```
44
+
45
+ ```tsx
46
+ <PlayerProvider
47
+ config={{pip: {enabled: true, autoEnterOnLeave: true, chromeNativeId: 'player-chrome'}}}>
48
+ ```
49
+
50
+ The `nativeID` literal belongs to the consumer; the library never hardcodes one of its own.
51
+ Omit `chromeNativeId` if your app draws no chrome of its own — the library then enters
52
+ Picture-in-Picture without hiding anything. If the id is set and **no view carries it**, the
53
+ library **refuses** the entry and logs a warning naming the id: entering PiP with the chrome
54
+ still mounted paints the app's dead chrome into the PiP window, which is the defect this
55
+ release exists to fix.
56
+
57
+ ### Removed
58
+
59
+ - **The `onUserLeaveHint` JS event.** The library now performs the HOME-path Picture-in-Picture
60
+ entry itself, so the event's only consumer — a consumer that drove the entry from JavaScript —
61
+ is the path the library took over. Leaving it would be a double-entry footgun: the OS would
62
+ refuse the second entry, the consumer would read that refusal as "PiP failed", and the chrome
63
+ would come back over a live PiP window.
64
+
65
+ This is a **public API removal**, which is why the release is 3.2.0 and not a patch. The bridge
66
+ now emits **26** named events; the list has one owner, `ALL_PLAYER_EVENTS` in
67
+ `src/bridge/MpvPlayerModule.ts`.
68
+
69
+ ### Changed
70
+
71
+ - `MpvBridgeModule.notifyUserLeaveHint()` is now
72
+ `notifyUserLeaveHint(activity: Activity): Boolean`. It takes the Activity — the entry happens
73
+ on it, and the chrome is searched under its window — and returns the OS's own answer:
74
+ `true` when the Activity entered Picture-in-Picture.
75
+ - **The PiP parameters have ONE owner.** The JS path (`enterPip`) and the native path
76
+ (`notifyUserLeaveHint`) build them through the same function, so the two cannot drift apart.
77
+ - The native path reports the title from mpv's `media-title` — which IS the title the consumer
78
+ supplied, because the library writes it as mpv's `force-media-title` before the load — and the
79
+ percentage from `time-pos` over `duration`, in the consumer's exact `"NN %"` format.
80
+
81
+ ### Documentation
82
+
83
+ - Five places in this library still carried the false claim that "an Activity in
84
+ Picture-in-Picture does not redraw". The accurate statement is that an Activity in PiP is
85
+ **"paused, but rendering"** (AOSP) — the window keeps rendering; what stops is **REACT**,
86
+ because React Native pauses the React scheduler with the Activity. The ORDER still matters — the
87
+ PiP window keeps whatever the Activity's window held at the transition — but the REASON was
88
+ wrong, and a wrong reason sends the next reader looking for the fix in the wrong place.
89
+ Corrected in `MpvBridgeModule.kt`, `CHANGELOG.md`, `README.md`, `MpvPlayerModule.ts` and
90
+ `config.ts`.
91
+
92
+ ### Added
93
+
94
+ - `PipConfig.chromeNativeId` — the `nativeID` of the consumer's chrome root, the view the
95
+ library hides natively on the HOME path.
96
+ - `PipNativeEntryTest` — 24 guard tests for the native HOME-path entry: the three refusals and
97
+ the order they come in, the chrome hidden with `GONE` **before** the PiP request, a refused
98
+ entry restoring the chrome, Picture-in-Picture ending restoring the chrome, the title read from
99
+ mpv's `media-title`, the percentage read from `time-pos`/`duration` in the consumer's exact
100
+ `"NN %"` format, one params builder for both paths, and the retired event's absence from the
101
+ event list.
102
+
2
103
  ## [3.1.0] - 2026-11-03
3
104
 
4
105
  ### Fixed
@@ -34,7 +135,7 @@
34
135
 
35
136
  - The README described the **removed** mechanism: Android's own auto-enter switch, an API 31+
36
137
  floor for auto-enter, a PiP action receiver "declared in the manifest", and 26 named
37
- events where there are 27. It also pointed at a section for "the two lines of Kotlin and
138
+ events where the bridge had 27. It also pointed at a section for "the two lines of Kotlin and
38
139
  the JS that goes with them" that did not contain them. All corrected; the auto-enter
39
140
  section now carries the Kotlin and the JS a consumer needs, and explains why the consumer
40
141
  performs the entry.
@@ -55,9 +156,11 @@
55
156
  `PictureInPictureParams.Builder.setAutoEnterEnabled` (API 31+), which makes
56
157
  the SYSTEM transition the activity into PiP when the user leaves the app,
57
158
  with the consumer unable to do anything first. That is the wrong order for a
58
- consumer that draws its own chrome over the picture, because **an Activity in
59
- PiP does not redraw**: whatever its window held at the transition is what
60
- the PiP window keeps showing. Measured on device on 2026-11-03, the
159
+ consumer that draws its own chrome over the picture, because an Activity in
160
+ PiP is "paused, but rendering" (AOSP) - what stops is REACT: RN pauses the
161
+ React scheduler with the Activity, so a React commit cannot land and no frame
162
+ is produced. So whatever its window held at the transition is what the PiP
163
+ window keeps showing. Measured on device on 2026-11-03, the
61
164
  consumer's full expanded chrome was painted into the PiP window, its
62
165
  buttons were dead, and its clock was frozen three minutes behind the real
63
166
  position.
@@ -70,13 +173,18 @@
70
173
  to the `onUserLeaveHint` event in JS; both are in the README's
71
174
  Picture-in-Picture section.
72
175
 
176
+ (History: that event is **retired in 3.2.0**, and the entry itself moved
177
+ into the library — it is performed natively, inside `onUserLeaveHint()`,
178
+ because by then no React commit can land. See the 3.2.0 entry above.)
179
+
73
180
  A side effect worth knowing: auto-enter now works on **every** API level.
74
181
  The platform's switch never existed below Android 12; `onUserLeaveHint()`
75
182
  does.
76
183
 
77
- - **`onUserLeaveHint` is the 27th player event.** It is emitted with an empty
78
- payload, and only when the auto-enter policy says yes — a consumer that
79
- turned auto-enter off is never asked to enter PiP.
184
+ - **`onUserLeaveHint` was the 27th player event.** It was emitted with an
185
+ empty payload, and only when the auto-enter policy says yes — a consumer that
186
+ turned auto-enter off was never asked to enter PiP. (The event was removed in
187
+ 3.2.0; the bridge emits 26 events now.)
80
188
 
81
189
  - **The bridge no longer stashes PiP params on the Activity.**
82
190
  `Activity.setPictureInPictureParams` and the helper that pushed them
package/README.md CHANGED
@@ -145,9 +145,9 @@ Your launcher Activity has to opt in:
145
145
  `resizeableActivity="true"` is not optional. An Activity that is not resizeable cannot enter
146
146
  Picture-in-Picture.
147
147
 
148
- If `config.pip.autoEnterOnLeave` is on, the Activity also has to forward the platform’s leave
149
- hint to the library — see [Picture-in-Picture](#picture-in-picture) for the two lines of Kotlin
150
- and the JS that goes with them.
148
+ If `config.pip.autoEnterOnLeave` is on, the Activity also has to hand the leave hint to the
149
+ library, which performs the Picture-in-Picture entry itself - see
150
+ [Picture-in-Picture](#picture-in-picture) for the two lines of Kotlin that go with it.
151
151
 
152
152
  ### Background audio
153
153
 
@@ -314,7 +314,7 @@ there is no library-owned overlay; the absolutely positioned `View` above is you
314
314
  | Section | Fields | Default |
315
315
  | --- | --- | --- |
316
316
  | `theme` | `accent`, `background`, `text`, `textSecondary`, `surface`, `icon?` | `#FFD700`, `#121216`, `#FFFFFF`, `rgba(255,255,255,0.6)`, `rgba(255,255,255,0.1)` |
317
- | `pip` | `enabled`, `autoEnterOnLeave` | `true`, `true` |
317
+ | `pip` | `enabled`, `autoEnterOnLeave`, `chromeNativeId?` | `true`, `true`, none |
318
318
  | `hardwareDecoding` | `'auto' \| 'mediacodec' \| 'no'` | `'auto'` |
319
319
  | `notifications` | `enabled`, `channelId` | `true`, `'simba_player_media'` |
320
320
  | `audio` | `backgroundPlayback`, `respectAudioFocus` | `true`, `true` |
@@ -336,8 +336,8 @@ import {PlayerProvider} from '@simba-dev/react-native-media-player';
336
336
  ```
337
337
 
338
338
  The resolved config is pushed to the native bridge as JSON. The native side acts on the PiP
339
- section (it decides whether your app is told that the user is leaving); the remaining
340
- sections are values your app reads back with `usePlayerConfig()` and applies itself.
339
+ section (the auto-enter policy, and the `nativeID` of your chrome root); the remaining sections
340
+ are values your app reads back with `usePlayerConfig()` and applies itself.
341
341
  `DEFAULT_PLAYER_CONFIG` and `DEFAULT_THEME` are exported if you would rather spread and patch.
342
342
 
343
343
 
@@ -359,40 +359,81 @@ declare `android:supportsPictureInPicture="true"` (see [Consumer setup](#consume
359
359
  **Auto-enter on leave** is `config.pip.autoEnterOnLeave` (default `true`): it means "enter
360
360
  Picture-in-Picture when the user leaves the app".
361
361
 
362
- **Your app performs the entry.** The library does not arm Android's own auto-enter switch
363
- (`PictureInPictureParams.Builder.setAutoEnterEnabled`), because an Activity in
364
- Picture-in-Picture does not redraw: whatever its window held at the moment of the transition is
365
- what the PiP window keeps showing. Letting the OS transition the Activity first froze the
366
- app's own controls into the PiP window, scaled down and dead - measured on device on
367
- 2026-11-03.
368
-
369
- So the order is yours to keep: take your chrome off screen, let the frame that drew it go by,
370
- and only then ask for the window. The library tells you WHEN, with two pieces.
362
+ **The library performs that entry, natively.** Two lines of Kotlin in your Activity:
371
363
 
372
364
  ```kotlin
373
365
  // android/app/src/main/java/.../MainActivity.kt
374
366
  override fun onUserLeaveHint() {
375
367
  super.onUserLeaveHint()
376
- com.simba.player.mpv.MpvBridgeModule.notifyUserLeaveHint()
368
+ com.simba.player.mpv.MpvBridgeModule.notifyUserLeaveHint(this)
377
369
  }
378
370
  ```
379
371
 
380
- ```ts
381
- // the consumer's JS - remove your chrome, then ask for the window
382
- import {subscribePlayerEvent} from '@simba-dev/react-native-media-player';
383
-
384
- useEffect(() => {
385
- return subscribePlayerEvent('onUserLeaveHint', () => {
386
- setChromeVisible(false); // your chrome, your state
387
- requestAnimationFrame(() => {
388
- commands.enterPip(); // only now
389
- });
390
- });
391
- }, [commands]);
372
+ The library then hides your chrome, asks the OS for the window, and brings your chrome back when
373
+ Picture-in-Picture ends. It returns whether the OS accepted the entry, so you can log it:
374
+
375
+ ```kotlin
376
+ val entered = com.simba.player.mpv.MpvBridgeModule.notifyUserLeaveHint(this)
377
+ ```
378
+
379
+ ### Why it is native, and why your Activity hands over the Activity
380
+
381
+ `Activity.onUserLeaveHint()` is the only hook Android gives you BEFORE the Activity is paused.
382
+ `onPictureInPictureModeChanged(true)` arrives after `onPause`, which is too late to change what
383
+ the window holds.
384
+
385
+ And by then, React Native has already paused the React scheduler with the Activity, so a React
386
+ commit cannot land and there is no frame clock. Measured on emulator-5554 (API 37) on 2026-11-03:
387
+ the JS handler ran immediately, the effect that would have driven the entry ran **5.7 s late**, and
388
+ the `requestAnimationFrame` **never fired**. So the entry has to happen in native code, and the
389
+ chrome has to be hidden with a native View-system mutation (`visibility = View.GONE`), which lands
390
+ without a React commit and without a frame clock.
391
+
392
+ An Activity in Picture-in-Picture is "paused, but rendering" (AOSP) - the window keeps rendering;
393
+ what stops is REACT. So the PiP window keeps whatever your window held at the moment of the
394
+ transition: the chrome has to be GONE before the entry.
395
+
396
+ ### Telling the library which view is your chrome
397
+
398
+ If your app draws its own chrome over the picture, give that view a `nativeID` and tell the library
399
+ about it:
400
+
401
+ ```tsx
402
+ // the consumer's JS - the chrome root
403
+ <View nativeID="player-chrome" style={styles.chrome}>
404
+ {/* your controls */}
405
+ </View>
406
+ ```
407
+
408
+ ```tsx
409
+ // the consumer's config
410
+ <PlayerProvider
411
+ config={{
412
+ pip: {enabled: true, autoEnterOnLeave: true, chromeNativeId: 'player-chrome'},
413
+ }}>
414
+ <App />
415
+ </PlayerProvider>
392
416
  ```
393
417
 
394
- This works on **every** Android version - `onUserLeaveHint()` exists everywhere, and the
395
- platform's own switch never existed below Android 12.
418
+ The library finds that view with React Native's own lookup (`ReactFindViewUtil.findView`), under
419
+ your Activity's window decor view, and hides it natively before it asks for the window. The
420
+ `nativeID` literal is yours - the library never hardcodes one of its own.
421
+
422
+ Omit `chromeNativeId` if your app draws no chrome of its own: the library then enters
423
+ Picture-in-Picture without hiding anything.
424
+
425
+ **If the `nativeID` is set and no view carries it, the library REFUSES the entry** and logs a
426
+ warning naming the id. Entering Picture-in-Picture with the chrome still mounted paints your dead
427
+ controls into the PiP window, scaled down and dead - that is the defect this path exists to fix, so
428
+ the library declines rather than reproduce it.
429
+
430
+ The library deliberately does NOT arm Android's own auto-enter switch
431
+ (`PictureInPictureParams.Builder.setAutoEnterEnabled`): that makes the OS transition the Activity
432
+ with no chance to remove your chrome, and the chrome it froze into the PiP window on 2026-11-03 was
433
+ scaled down and dead.
434
+
435
+ This works on **every** Android version - `onUserLeaveHint()` exists everywhere, and the platform's
436
+ own switch never existed below Android 12.
396
437
 
397
438
  The two PiP flags combine: auto-enter needs `pip.enabled` and `pip.autoEnterOnLeave` to both be
398
439
  true.
@@ -484,7 +525,7 @@ that position in that file. The defaults are 640×360 at quality 80, exported as
484
525
 
485
526
  `getMpvPlayerModule()` returns the native module, or a no-op stand-in when the native side is
486
527
  not wired (Jest, web previews) so consumer code stays renderable.
487
- `subscribePlayerEvent(name, handler)` subscribes to one of the 27 named events and returns an
528
+ `subscribePlayerEvent(name, handler)` subscribes to one of the 26 named events and returns an
488
529
  unsubscribe function; `removeAllListeners()`, `setDebugLogging()` and
489
530
  `dumpObservedProperties()` are also exported. The event names are typed as `PlayerEventName`.
490
531
 
@@ -501,8 +542,10 @@ before launching, and check `commands.isSurfaceMounted()`.
501
542
 
502
543
  **Picture-in-Picture does not start.** The Activity is missing
503
544
  `android:supportsPictureInPicture="true"` or `android:resizeableActivity="true"`. If auto-enter
504
- on leave does nothing, the Activity is not forwarding `onUserLeaveHint()` - see
505
- [Picture-in-Picture](#picture-in-picture).
545
+ on leave does nothing, the Activity is not calling `MpvBridgeModule.notifyUserLeaveHint(this)`
546
+ from `onUserLeaveHint()` - see [Picture-in-Picture](#picture-in-picture). If the log says the
547
+ library refused the entry because no view carries your chrome `nativeID`, the `nativeID` in your
548
+ config does not match the one on the view.
506
549
 
507
550
  **The Picture-in-Picture action row shows three buttons and none of them work.** That was the
508
551
  explicit-broadcast bug, fixed in 3.1.0: the action's PendingIntent named the receiver's
@@ -527,9 +570,9 @@ Call `commands.requestNotificationPermission()`.
527
570
 
528
571
  - **Android only.** There is no iOS implementation.
529
572
  - **No controls.** The library ships none; see [Controls](#controls).
530
- - **Auto-enter on leave is the consumer's to perform.** The library tells your Activity when the
531
- user is leaving; taking your chrome off screen before asking for the window is your app's
532
- job, and it has to happen before the Activity is paused.
573
+ - **Auto-enter on leave is performed by the library, from your Activity.** Your Activity hands
574
+ over the leave hint and the library enters Picture-in-Picture natively, because by then no
575
+ React commit can land. Your app's own job is the `nativeID` of the chrome the library hides.
533
576
  - **Most config sections are consumed in JavaScript.** The native side receives the resolved
534
577
  config as JSON and acts on the PiP auto-enter policy; the rest are values your app reads back
535
578
  through `usePlayerConfig()`.
@@ -178,15 +178,16 @@ object PipManager {
178
178
  // own state already said `pipActive: true` and `isExpanded:
179
179
  // false`.
180
180
  //
181
- // So auto-enter on leave is the CONSUMER's to perform, in the only
182
- // order that works: remove the chrome, let the frame that drew it
183
- // go by, and only then ask for the window. The library's part is
184
- // to tell the consumer WHEN the user is leaving - the
185
- // `onUserLeaveHint` event - and to keep the params it hands the
186
- // platform free of the platform's own auto-enter switch.
181
+ // So auto-enter on leave is performed by the LIBRARY, natively, in
182
+ // the only order that works: hide the chrome, then ask for the
183
+ // window. The library's part is to hide the consumer's chrome
184
+ // natively (a View-system mutation, so it lands without a React
185
+ // commit) and to keep the params it hands the platform free of
186
+ // the platform's own auto-enter switch.
187
187
  //
188
- // The consumer's Activity overrides `onUserLeaveHint()`, which
189
- // works on every API level, unlike the platform switch (API 31+).
188
+ // The consumer's Activity overrides `onUserLeaveHint()` and calls
189
+ // `MpvBridgeModule.notifyUserLeaveHint(activity)`, which works on
190
+ // every API level, unlike the platform switch (API 31+).
190
191
 
191
192
  // Source rect hint for smooth entry animation (Android 12+)
192
193
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && sourceRectHint != null) {
@@ -0,0 +1,86 @@
1
+ package com.simba.player
2
+
3
+ /**
4
+ * The PURE facts of the native Picture-in-Picture entry.
5
+ *
6
+ * ## Why this file exists
7
+ *
8
+ * The HOME path enters PiP from NATIVE code — `MpvBridgeModule`'s
9
+ * companion, `notifyUserLeaveHint(activity)` — because by the time the
10
+ * user presses HOME, React Native has already paused the React
11
+ * scheduler with the Activity: a React commit cannot land and there is
12
+ * no frame clock. Measured on emulator-5554 (API 37) on 2026-11-03: the
13
+ * JS handler ran immediately, the effect that would have driven the
14
+ * entry ran 5.7 s late, and the `requestAnimationFrame` never fired.
15
+ *
16
+ * That native path has to produce the SAME two facts the JS path
17
+ * produces — a title and a progress percentage — and it has to format
18
+ * them the SAME way, because the PiP notification is one surface with
19
+ * two writers. A title that differs by a quote character and a
20
+ * percentage that differs by a space are two different facts about one
21
+ * playing item.
22
+ *
23
+ * So the formatting lives HERE, in plain Kotlin with no Android classes
24
+ * in it, and BOTH paths call it. That is what makes it testable on a
25
+ * plain JVM: these are the functions the unit tests exercise, and they
26
+ * need neither Robolectric nor a device nor a network download to run.
27
+ *
28
+ * ## What is deliberately NOT here
29
+ *
30
+ * Anything that touches Android (`View`, `Activity`,
31
+ * `PictureInPictureParams`) or mpv (`MPVLib`) stays in
32
+ * `MpvBridgeModule`. This file holds no state and has no side effects.
33
+ */
34
+ internal object PipNativeEntry {
35
+
36
+ /**
37
+ * The consumer's chrome `nativeID`, read from the RESOLVED config.
38
+ *
39
+ * The literal belongs to the CONSUMER: the library stores it and
40
+ * uses it, and never hardcodes one of its own. `null` means "this
41
+ * consumer has no chrome of its own", which is a real answer and
42
+ * not a missing value — the native path then has nothing to hide.
43
+ */
44
+ fun chromeNativeId(config: Map<String, Any?>?): String? {
45
+ val pip = config?.get("pip") as? Map<*, *> ?: return null
46
+ val raw = pip["chromeNativeId"] as? String ?: return null
47
+ return raw.trim().takeIf { it.isNotEmpty() }
48
+ }
49
+
50
+ /**
51
+ * mpv's `media-title` as a title, or `null` when there is none.
52
+ *
53
+ * mpv's properties come back JSON-encoded, so a string arrives
54
+ * wrapped in quotes (`"Overrun!"`), and a property that is not set
55
+ * arrives as the literal `null` — which is NOT a title.
56
+ *
57
+ * The title the consumer supplied is in here, and it is the SAME
58
+ * fact and not a second one: the library writes it as mpv's
59
+ * `force-media-title` BEFORE the load, and mpv reports it back as
60
+ * `media-title`.
61
+ */
62
+ fun title(raw: String?): String? {
63
+ val trimmed = raw?.trim()?.trim('"')?.trim() ?: return null
64
+ if (trimmed.isEmpty()) return null
65
+ if (trimmed.equals("null", ignoreCase = true)) return null
66
+ return trimmed
67
+ }
68
+
69
+ /**
70
+ * The progress percentage, formatted exactly as the consumer
71
+ * formats it: an integer, a space, then `%` — `"45 %"`.
72
+ *
73
+ * `null` when there is no duration to divide by. A percentage of an
74
+ * unknown length is not a fact.
75
+ *
76
+ * The rounding is JavaScript's `Math.round`, which is
77
+ * `floor(x + 0.5)` — not the "ties to even" rule, so the native
78
+ * path and the JS path cannot disagree by one percent on a .5
79
+ * boundary.
80
+ */
81
+ fun progressPct(positionMs: Long, durationMs: Long): String? {
82
+ if (durationMs <= 0L) return null
83
+ val ratio = (positionMs.toDouble() / durationMs.toDouble()) * 100.0
84
+ return "${kotlin.math.floor(ratio + 0.5).toInt()} %"
85
+ }
86
+ }