'Flutter just_audio - why is setting audio source as LockCachingAudioSource failing?

I am greatly interested in using the LockCachingAudioSource feature in Flutter's just_audio package, but I am noticing a strange behavior I can't quite get to the bottom of.

Some audio files fail to be loaded using LockCachingAudioSource. When trying to load the file using

await _audioPlayer.setAudioSource(LockCachingAudioSource(Uri.parse(item.audioUri)));

I receive the exception:

Unhandled Exception: (-11828) Cannot Open
#0      AudioPlayer._load (package:just_audio/just_audio.dart:778:9)
<asynchronous suspension>
#1      AudioPlayer._setPlatformActive.setPlatform (package:just_audio/just_audio.dart:1346:28)
<asynchronous suspension>

In order to debug this, I have tried running the exact same on just_audio's example/lib/example_caching.dart file. Bizarrely, the code, with the exact same URL, works here.

I am greatly struggling to determine whether this is a problem with my specific project or the plugin itself. Another observation I have made is that audio files recorded and uploaded prior to migrating to Flutter 2.0+ seem to work, while files recorded afterwards don't (but they still work on the example project). Additionally, I have confirmed that content-type headers are correct (audio/mp4). I have followed the installation instructions in just_audio's documentation.



Solution 1:[1]

Because some audio URLs do not support range requests.

Here is the reference

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Shahriar Nasim Nafi