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!
The text was updated successfully, but these errors were encountered:
Oops, it appears that your issue did not follow the template and is missing one or more required sections. Please open a new issue, and provide all required sections and information.
FAQ:
Do I really need to submit a minimal reproduction project for a bug? A: Yes. I prioritise bugs secondarily on how many people are affected, and primarily on whether the bug report is complete, in the sense that it enables me to immediately reproduce it and start working on a fix. If a bug is important to you, the best thing you can do is to provide all requested information ASAP so that I can start looking into it ASAP.
I think I supplied all required information, so did the bot make a mistake? A: The bot only checks the section headings, so when you post a new issue, make sure you leave the section headings intact. (Note that because of this, it is even possible to trick the bot by including only the section headings, and then not providing the requested information under each heading. This is frowned upon, and the issue will be closed manually.)
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs, or use StackOverflow if you need help with just_audio.
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.)
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
The text was updated successfully, but these errors were encountered: