Skip to content

[ios][audio] Support native preloading#43061

Merged
alanjhughes merged 1 commit intomainfrom
alanhughes/audio/ios-preloading
Feb 19, 2026
Merged

[ios][audio] Support native preloading#43061
alanjhughes merged 1 commit intomainfrom
alanhughes/audio/ios-preloading

Conversation

@alanjhughes
Copy link
Copy Markdown
Collaborator

@alanjhughes alanjhughes commented Feb 11, 2026

Why

closes #42900
Adds support for native preloading

How

Adds a preload function and cache that allows users to create a player instance and start loading the buffer ahead of when useAudioPlayer is used in the component. When a url is used that exist's in the cache, we return the preloaded AVPlayer instance.

Test Plan

Bare expo

Copy link
Copy Markdown
Collaborator Author

alanjhughes commented Feb 11, 2026

@expo-bot
Copy link
Copy Markdown
Collaborator

expo-bot commented Feb 11, 2026

The Pull Request introduced fingerprint changes against the base commit: a88fab5

Fingerprint diff
[
  {
    "op": "changed",
    "beforeSource": {
      "type": "dir",
      "filePath": "../../packages/expo-audio/ios",
      "reasons": [
        "expoAutolinkingIos"
      ],
      "hash": "7483c01f05528676ffaddc1106f124e14532de18"
    },
    "afterSource": {
      "type": "dir",
      "filePath": "../../packages/expo-audio/ios",
      "reasons": [
        "expoAutolinkingIos"
      ],
      "hash": "dc19b7c91768bb26b185907ae492b2b994b718af"
    }
  }
]

Generated by PR labeler 🤖

@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label Feb 11, 2026
@alanjhughes alanjhughes force-pushed the alanhughes/audio/ios-preloading branch 5 times, most recently from 57c43f2 to 1a9a726 Compare February 13, 2026 11:27
@alanjhughes alanjhughes marked this pull request as ready for review February 13, 2026 12:21
@github-actions
Copy link
Copy Markdown
Contributor

Subscribed to pull request

File Patterns Mentions
packages/expo-audio/** @behenate

Generated by CodeMention

@alanjhughes alanjhughes force-pushed the alanhughes/audio/ios-preloading branch 2 times, most recently from 64f3a65 to 7ecd857 Compare February 13, 2026 12:37
@psnet
Copy link
Copy Markdown
Contributor

psnet commented Feb 13, 2026

@alanjhughes thanks for working on this!

I want to mention that audio has prop isLoaded:

https://docs.expo.dev/versions/latest/sdk/audio/#isloaded

which is kinda useless (it doesnt really show audio is ready to play)

and there is isBuffering:

https://docs.expo.dev/versions/latest/sdk/audio/#isbuffering

which works in way you cannot rely on it.


So maybe add another status prop like isBufferedToPlay to indicate that player will play asap with minimum latency (some or all data is really buffered).

Because of this, neither isLoaded nor isBuffering are currently not suitable for case "when?" you can play audio.

@alanjhughes
Copy link
Copy Markdown
Collaborator Author

@psnet

So maybe add another status prop like isBufferedToPlay to indicate that player will play asap with minimum latency (some or all data is really buffered).

What values outside of what we are already using are provided by the native SDKs would be used to determine that?

@psnet
Copy link
Copy Markdown
Contributor

psnet commented Feb 13, 2026

@alanjhughes

What values outside of what we are already using are provided by the native SDKs would be used to determine that?

Right now I dont know, I just want to mention that current statuses isLoaded and isBuffering are not really helpful. And asked maybe you have ideas how to improve this case?

@alanjhughes
Copy link
Copy Markdown
Collaborator Author

@psnet - Ok, I will try out some things and see if this can be improved

@alanjhughes
Copy link
Copy Markdown
Collaborator Author

@psnet - you can also check the playbackState for readyToPlay

@psnet
Copy link
Copy Markdown
Contributor

psnet commented Feb 13, 2026

@alanjhughes

@psnet - you can also check the playbackState for readyToPlay

on web it is unimplemented (always empty):

https://github.com/expo/expo/blob/main/packages/expo-audio/src/AudioModule.web.ts#L89

on android:

it is the same as isBuffering:

Property("isBuffering") { player ->
runOnMain {
player.ref.playbackState == Player.STATE_BUFFERING
}
}

and as isLoaded:

Property("isLoaded") { player ->
runOnMain {
player.ref.playbackState == Player.STATE_READY
}
}

@alanjhughes alanjhughes force-pushed the alanhughes/audio/ios-preloading branch 2 times, most recently from 03a7939 to 39d2142 Compare February 16, 2026 15:33
@expo-bot expo-bot added bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels Feb 16, 2026
@alanjhughes alanjhughes force-pushed the alanhughes/audio/ios-preloading branch from 39d2142 to 7c67a9d Compare February 16, 2026 15:49
@alanjhughes alanjhughes force-pushed the alanhughes/audio/ios-preloading branch from 7c67a9d to 1fbb601 Compare February 17, 2026 11:42
@expo-bot expo-bot added bot: suggestions ExpoBot has some suggestions and removed bot: passed checks ExpoBot has nothing to complain about labels Feb 17, 2026
@alanjhughes alanjhughes force-pushed the alanhughes/audio/ios-preloading branch 3 times, most recently from a45fd35 to 5dc5ec1 Compare February 19, 2026 10:13
@alanjhughes alanjhughes force-pushed the alanhughes/audio/ios-preloading branch from 5dc5ec1 to bc10a3f Compare February 19, 2026 11:07
@expo-bot
Copy link
Copy Markdown
Collaborator

Hi there! 👋 I'm a bot whose goal is to ensure your contributions meet our guidelines.

I've found some issues in your pull request that should be addressed (click on them for more details) 👇

⚠️ Suggestion: Missing changelog entries


Your changes should be noted in the changelog, e.g.:
- [audio] Support native preloading ([#43061](https://github.com/expo/expo/pull/43061) by [@alanjhughes](https://github.com/alanjhughes))
Read Updating Changelogs guide and consider adding an appropriate entry to the following changelogs:


Generated by ExpoBot 🤖 against bc10a3f

Copy link
Copy Markdown
Collaborator Author

alanjhughes commented Feb 19, 2026

Merge activity

  • Feb 19, 11:54 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Feb 19, 11:54 AM UTC: @alanjhughes merged this pull request with Graphite.

@alanjhughes alanjhughes merged commit ca793d7 into main Feb 19, 2026
13 checks passed
@alanjhughes alanjhughes deleted the alanhughes/audio/ios-preloading branch February 19, 2026 11:54
benjaminkomen pushed a commit to benjaminkomen/expo that referenced this pull request Feb 25, 2026
# Why
closes expo#42900
Adds support for native preloading

# How
Adds a `preload` function and cache that allows users to create a player instance and start loading the buffer ahead of when `useAudioPlayer` is used in the component. When a url is used that exist's in the cache, we return the preloaded `AVPlayer` instance.

# Test Plan
Bare expo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[expo-audio] sound preloading not implemented

4 participants