Skip to content

fix: stream audio files that are not downloaded - #4526

Merged
marinofaggiana merged 2 commits into
masterfrom
fix/audio-streaming
Dec 5, 2026
Merged

marinofaggiana merged 2 commits into
masterfrom
fix/audio-streaming

Conversation

@marinofaggiana

Copy link
Copy Markdown
Member

Summary

Audio files that are not on the device now start playing at once, streamed from the server, instead of being downloaded in full first.

Since the new media viewer (33.1.0), an audio file had to be downloaded completely before it could play, so a long recording or podcast started only after the whole file arrived. The viewer also released that copy once the page left its buffer, so playing it again downloaded it again. Earlier versions streamed audio, and video still does. A tester reported this as a regression on TestFlight.

  • Audio now plays from the same direct download link video uses (NCVideoURLResolver), through the new NCMediaViewerLoading.streamingURL(for:).
  • The file is still downloaded before playback when no link can be created, or when the server uses a certificate the user trusted manually, which AVPlayer cannot use (the same rule video follows).
  • Files already on the device keep playing from local storage.
  • The audio page state's URL is now named url instead of localURL, because it can be a remote URL.

Testing

Ran NextcloudUnitTests locally: all 234 tests pass. On the iPhone Duo simulator against a local Nextcloud 35 server, opened a 7:41 .m4a that was not downloaded: playback started at once, the server log showed only range requests (206) on the direct link and no full download, and play, pause and the 10-second skips worked. Not tested on a device or on a slow network.

Suggested checks on a live Nextcloud instance:

  1. Open a long audio file (for example a 50 MB podcast) that is not downloaded: it starts within a few seconds and the slider can jump ahead.
  2. Open an audio file that is already downloaded: it plays from the device, also in airplane mode.
  3. On a server with a self-signed certificate trusted in the app, an audio file is downloaded first and then plays, as before.

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

🤖 Generated with Claude Code

Since the new media viewer, an audio file that was not on the device was
downloaded in full before it could play, so a long recording or podcast
started only after the whole file arrived. The viewer also released that
copy once the page left its buffer, so playing it again downloaded it
again. Earlier versions streamed audio, and video still does.

Audio now plays from the same direct download link video uses. It is
downloaded first only when no link can be created or when the server
uses a certificate the user trusted manually, which AVPlayer cannot use.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
@marinofaggiana marinofaggiana self-assigned this Dec 5, 2026
@marinofaggiana
marinofaggiana merged commit bb98d97 into master Dec 5, 2026
6 checks passed
@marinofaggiana
marinofaggiana deleted the fix/audio-streaming branch December 5, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant