You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which API doesn't behave as documented, and how does it misbehave?
I'm working on a project that uses the just_audio package, but with the following requirements:
The audio file is encrypted;
The audio needs to be played as a stream of bytes.
I tried to manually implement a StreamAudioSource, but it didn't work out very well, so I decided to adapt the LockCachingAudioSource class (I renamed it CustomAudioSource), with an additional parameter to inform the decryptor to be used when downloading bytes. My idea is to use it as follows: setAudioSource(CustomAudioSource(url: "https://encrypted.mp3.aes", decrypter: ...)). Doing it this way works perfectly on Android, but on iOS the player "doesn't play". I spent a lot of time trying to understand the behavior, and I noticed the following:
The download and decryption work perfectly. I can even play the generated file on other audio players on my computer, for example;
If I use AudioSource.file, passing the path of the generated file, the iOS player works perfectly;
The player only gives an error with my url "https://encrypted.mp3.aes". Any other "normal" audio url (a free sample from a test site, for example) works perfectly;
In the end, I ended up stuck with AVPlayer (which is used under the hood in just_audio). From what I understand, it requests some initial bytes of my encrypted url to decide if it can play the entire file, but this ends up breaking the entire execution of setAudioSource.
I would like to solve this problem inside my CustomAudioSource class (to avoid a fork of just_audio), but I've run out of ideas. Do you have any suggestions?
(sorry for any English mistakes, I'm using Translator)
Expected behavior
The player is expected to... play.
I imagined that, since it is a StreamAudioSource, just the decrypted bytes stream would be enough to use in the player's playback. However, the source URL is passed internally to AVPlayer, and, consequently, breaks the entire playback.
Screenshots
All from example/lib/main:
Switch between sources. Encrypted fails, "normal" works fine (without decrypter generator, obviously).
Desktop (please complete the following information):
OS: MacOS Sonoma 14.5
Smartphone (please complete the following information):
Android [Success]
Device: (Simulator) Pixel 3a
OS: Android 14
iOS [Error]
Device: (Simulator) iPhone 15 Pro Max
OS: iOS 17.5
Flutter SDK version
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.22.3, on macOS 14.5 23F79 darwin-arm64, locale pt-BR)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.1)
[✓] VS Code (version 1.95.3)
[✓] Network resources
• No issues found!
Additional context
Not found any.
The text was updated successfully, but these errors were encountered:
Which API doesn't behave as documented, and how does it misbehave?
I'm working on a project that uses the
just_audio
package, but with the following requirements:The audio file is encrypted;
The audio needs to be played as a stream of bytes.
I tried to manually implement a
StreamAudioSource
, but it didn't work out very well, so I decided to adapt theLockCachingAudioSource
class (I renamed itCustomAudioSource
), with an additional parameter to inform the decryptor to be used when downloading bytes. My idea is to use it as follows:setAudioSource(CustomAudioSource(url: "https://encrypted.mp3.aes", decrypter: ...))
. Doing it this way works perfectly on Android, but on iOS the player "doesn't play". I spent a lot of time trying to understand the behavior, and I noticed the following:The download and decryption work perfectly. I can even play the generated file on other audio players on my computer, for example;
If I use AudioSource.file, passing the path of the generated file, the iOS player works perfectly;
The player only gives an error with my url
"https://encrypted.mp3.aes"
. Any other "normal" audio url (a free sample from a test site, for example) works perfectly;In the end, I ended up stuck with
AVPlayer
(which is used under the hood injust_audio
). From what I understand, it requests some initial bytes of my encrypted url to decide if it can play the entire file, but this ends up breaking the entire execution ofsetAudioSource
.I would like to solve this problem inside my
CustomAudioSource
class (to avoid a fork of just_audio), but I've run out of ideas. Do you have any suggestions?(sorry for any English mistakes, I'm using Translator)
Minimal reproduction project
https://github.com/gileadeteixeira/encrypted_audio_source
(ignore README. it was created while I was testing the first version with my own version of StreamAudioSource.)
To Reproduce (i.e. user steps, not code)
run
example
see errors
Error messages
Expected behavior
The player is expected to... play.
I imagined that, since it is a StreamAudioSource, just the decrypted bytes stream would be enough to use in the player's playback. However, the source URL is passed internally to AVPlayer, and, consequently, breaks the entire playback.
Screenshots
All from
example/lib/main
:Switch between sources. Encrypted fails, "normal" works fine (without decrypter generator, obviously).
Desktop (please complete the following information):
Smartphone (please complete the following information):
Android [Success]
iOS [Error]
Flutter SDK version
Additional context
Not found any.
The text was updated successfully, but these errors were encountered: