Skip to content

[web][audio] Support preloading#43063

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

[web][audio] Support preloading#43063
alanjhughes merged 1 commit intomainfrom
alanhughes/audio/web-preloading

Conversation

@alanjhughes
Copy link
Copy Markdown
Collaborator

@alanjhughes alanjhughes commented Feb 11, 2026

Why

Supports preloading on web

How

Same approach as when downloadFirst was added except we also add audio.preload = 'auto'; Extracted some of the shared logic from downloadFirst so all forms of preloading go through the same mechanism and use the cache.

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: c558433

Fingerprint diff
[
  {
    "op": "changed",
    "beforeSource": {
      "type": "dir",
      "filePath": "../../packages/expo-audio/android",
      "reasons": [
        "expoAutolinkingAndroid"
      ],
      "hash": "1cd0d495d6e413bb5d360a2dacd330f39f79cae2"
    },
    "afterSource": {
      "type": "dir",
      "filePath": "../../packages/expo-audio/android",
      "reasons": [
        "expoAutolinkingAndroid"
      ],
      "hash": "09bf27ca49fddc7548516252fdad7e10a2ce791f"
    }
  },
  {
    "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"
    }
  },
  {
    "op": "changed",
    "beforeSource": {
      "type": "dir",
      "filePath": "../../packages/expo-image/android",
      "reasons": [
        "expoAutolinkingAndroid"
      ],
      "hash": "cbf9f66cd9364ef40c91e0c1dc1eff74089fe57c"
    },
    "afterSource": {
      "type": "dir",
      "filePath": "../../packages/expo-image/android",
      "reasons": [
        "expoAutolinkingAndroid"
      ],
      "hash": "e7f03fbc5f52732f66a401867fecb0ddb07534f1"
    }
  }
]

Generated by PR labeler 🤖

@alanjhughes alanjhughes force-pushed the alanhughes/audio/web-preloading branch from 298dec1 to ba2c7f0 Compare February 11, 2026 10:09
@expo-bot expo-bot added bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels Feb 11, 2026
@alanjhughes alanjhughes force-pushed the alanhughes/audio/web-preloading branch from ba2c7f0 to d6824ba Compare February 11, 2026 10:10
@alanjhughes alanjhughes force-pushed the alanhughes/audio/android-preloading branch 2 times, most recently from 7efb47c to e7f5871 Compare February 11, 2026 10:12
@alanjhughes alanjhughes force-pushed the alanhughes/audio/web-preloading branch 3 times, most recently from 19e8cce to f4ea64a Compare February 11, 2026 10:30
@alanjhughes alanjhughes force-pushed the alanhughes/audio/android-preloading branch from e7f5871 to f247fb7 Compare February 11, 2026 10:30
@alanjhughes alanjhughes force-pushed the alanhughes/audio/web-preloading branch from f4ea64a to aec5401 Compare February 11, 2026 12:42
@alanjhughes alanjhughes force-pushed the alanhughes/audio/android-preloading branch 2 times, most recently from 27aa220 to 1e5072c Compare February 12, 2026 11:18
@alanjhughes alanjhughes force-pushed the alanhughes/audio/web-preloading branch from aec5401 to 07e6c57 Compare February 12, 2026 11:18
@psnet
Copy link
Copy Markdown
Contributor

psnet commented Feb 13, 2026

@alanjhughes
Hi! Thanks for working on issue with preloading audio!

I want to note one thing about exactly "web" env: for web env you did almost the same that was done already:

https://github.com/expo/expo/blob/main/packages/expo-audio/src/ExpoAudio.web.ts#L35-L58
https://github.com/expo/expo/blob/main/packages/expo-audio/src/ExpoAudio.web.ts#L76-L118

that code preloads audio as Blob and replaces Audio when in it is loaded. And here is a catch:

  • first of all that code is write twice for 2 methods
  • that code is partially working (as buffering) for web only

Why partially? because of buffering on web can be done via preload prop (you did this in your PR) but in existing code there is no preload set.

This means some code for "web" is already have been done but not enough and that code is duplicated 2 times.

I think need to combine your code with Blob and preload prop with existing and replace duplicates.

P.S. Native still doesnt have any change of buffering. This comments is only about web

@alanjhughes alanjhughes force-pushed the alanhughes/audio/android-preloading branch from 1e5072c to a1564cc Compare February 13, 2026 11:27
@alanjhughes alanjhughes force-pushed the alanhughes/audio/web-preloading branch from 07e6c57 to b0b45ce Compare February 13, 2026 11:27
@alanjhughes
Copy link
Copy Markdown
Collaborator Author

@psnet - This is a draft PR and still being worked on. Also, it is part of a stack of PRs. See #43063 (comment) for the others with the native changes.

@alanjhughes alanjhughes force-pushed the alanhughes/audio/web-preloading branch from b0b45ce to 0412274 Compare February 13, 2026 11:46
@alanjhughes alanjhughes marked this pull request as ready for review February 13, 2026 12:20
@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/android-preloading branch from a1564cc to c3a4c23 Compare February 13, 2026 12:22
@alanjhughes alanjhughes force-pushed the alanhughes/audio/web-preloading branch from 4dab893 to ef131e5 Compare February 16, 2026 14:21
@alanjhughes alanjhughes force-pushed the alanhughes/audio/android-preloading branch from 1cd63f6 to d9b1ca3 Compare February 16, 2026 14:21
@alanjhughes alanjhughes force-pushed the alanhughes/audio/web-preloading branch from ef131e5 to fa5d9aa Compare February 16, 2026 15:33
@alanjhughes alanjhughes force-pushed the alanhughes/audio/android-preloading branch from d9b1ca3 to eb816a2 Compare February 16, 2026 15:33
@alanjhughes alanjhughes force-pushed the alanhughes/audio/web-preloading branch from fa5d9aa to fd2709f Compare February 16, 2026 15:49
@alanjhughes alanjhughes force-pushed the alanhughes/audio/android-preloading branch from eb816a2 to d4df148 Compare February 16, 2026 15:49
@alanjhughes alanjhughes force-pushed the alanhughes/audio/web-preloading branch 2 times, most recently from 997a625 to 7a39d85 Compare February 17, 2026 11:42
@alanjhughes alanjhughes force-pushed the alanhughes/audio/android-preloading branch from d4df148 to a851c36 Compare February 17, 2026 11:42
})
.catch(() => {
if (!isCancelled) {
player.replace(resolved);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's weird that we're replacing the source with an unsuccessful preload. Was that intentional?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not replacing with an unsuccessful preload, it's just using the original source url if it fails. When it goes through _createMediaElement the cache will be checked. It won't be there in this case so we just load it normally. I'll make it a finally block so there's no duplication

@alanjhughes alanjhughes force-pushed the alanhughes/audio/android-preloading branch from a851c36 to 956a40a Compare February 18, 2026 11:23
@alanjhughes alanjhughes force-pushed the alanhughes/audio/web-preloading branch 2 times, most recently from 40c2830 to 3010269 Compare February 18, 2026 11:35
@alanjhughes alanjhughes force-pushed the alanhughes/audio/android-preloading branch from 956a40a to 6fff3e3 Compare February 19, 2026 07:46
@alanjhughes alanjhughes force-pushed the alanhughes/audio/web-preloading branch 2 times, most recently from 3915d03 to 84762f9 Compare February 19, 2026 10:13
@alanjhughes alanjhughes force-pushed the alanhughes/audio/android-preloading branch from 6fff3e3 to 4ea9f60 Compare February 19, 2026 10:13
@alanjhughes alanjhughes force-pushed the alanhughes/audio/web-preloading branch from 84762f9 to 6777fb0 Compare February 19, 2026 11:07
@alanjhughes alanjhughes force-pushed the alanhughes/audio/android-preloading branch 2 times, most recently from 0988b69 to d1fa2c4 Compare February 19, 2026 11:14
@alanjhughes alanjhughes force-pushed the alanhughes/audio/web-preloading branch from 6777fb0 to bfcd976 Compare February 19, 2026 11:14
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:58 AM UTC: Graphite rebased this pull request as part of a merge.
  • Feb 19, 11:58 AM UTC: @alanjhughes merged this pull request with Graphite.

@alanjhughes alanjhughes changed the base branch from alanhughes/audio/android-preloading to graphite-base/43063 February 19, 2026 11:55
@alanjhughes alanjhughes changed the base branch from graphite-base/43063 to main February 19, 2026 11:56
@alanjhughes alanjhughes force-pushed the alanhughes/audio/web-preloading branch from bfcd976 to 2fdc151 Compare February 19, 2026 11:57
@alanjhughes alanjhughes merged commit a95d752 into main Feb 19, 2026
9 of 10 checks passed
@alanjhughes alanjhughes deleted the alanhughes/audio/web-preloading branch February 19, 2026 11:58
benjaminkomen pushed a commit to benjaminkomen/expo that referenced this pull request Feb 25, 2026
# Why
Supports preloading on web

# How
Same approach as when `downloadFirst` was added except we also add `audio.preload = 'auto';` Extracted some of the shared logic from `downloadFirst` so all forms of preloading go through the same mechanism and use the cache.

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

Labels

bot: fingerprint changed bot: passed checks ExpoBot has nothing to complain about

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants