Back

just_audio plugin flutter can not get duration.

  • 0
  • Self Hosted
  • Flutter
  • Storage
kaliz
12 Mar, 2023, 04:43
TL;DR
The user is experiencing issues with the just_audio plugin in Flutter. They are unable to get the duration of certain audio files. They provide links to different files and mention that they are testing on the Android platform. The user also asks for help in modifying the code to add a content-length header to the response. Another user suggests modifying a specific handler in the code. The user also asks for assistance in building a production image from source or changing the .env file. They also mention that they were able to get the duration of a specific audio file from a different source. Another user suggests modifying the status code or modifying the content-range to return
Drake
12 Mar, 2023, 04:48

Thanks for posting this here. I'll have to check a few things, but I may not have time until Monday

Drake
12 Mar, 2023, 04:49

Are you using the view or download endpoint?

Drake
12 Mar, 2023, 04:50

Is there any range headers in the request headers?

kaliz
12 Mar, 2023, 04:51

Using view link. but both link can not get duration. This is first request not include request range in headers. I open this link in browser by default and inspect this

Drake
12 Mar, 2023, 04:53

If you really want to modify the code, you can look into modifying this handler: https://github.com/appwrite/appwrite/blob/e8c74d7204258133a61db09ed518211170e751d9/app/controllers/api/storage.php#L1098

kaliz
12 Mar, 2023, 04:59

Trying modify I'm adding content-length by size but I don't know I can not see this in response. I'm add x-content-length for test and I can see this in response but not anything of content-length. Sorry but I'm stupid in server side code

kaliz
12 Mar, 2023, 05:04

response with status code 200

kaliz
12 Mar, 2023, 05:53

How can I build production image from source or just change .env file? Please give any document can help me

Drake
13 Mar, 2023, 06:29

honestly, i wouldn't build an image. i would just mount in a modified file

Drake
13 Mar, 2023, 06:29

anyways, I've done some testing and I do get a content-length for my files...

Drake
13 Mar, 2023, 06:30

also, I tested against this file: https://www2.cs.uic.edu/~i101/SoundFiles/BabyElephantWalk60.wav, but i couldn't get the duration from:

TypeScript
    const fileUrl =
        'https://www2.cs.uic.edu/~i101/SoundFiles/BabyElephantWalk60.wav';
    _player.setUrl(fileUrl).then((value) {
      setState(() {
        _duration = _player.duration;
      });
    });
Drake
13 Mar, 2023, 06:31
kaliz
13 Mar, 2023, 09:31

My app can get duration with your audio file, this is helpful for me. How can I modify it.

kaliz
13 Mar, 2023, 09:35

Need content-length in response with status code 200 not 206. Because just_audio read conent-length in first request with status code 200 and save it as duration

kaliz
13 Mar, 2023, 09:39

Look at your status code or modify content-range return full range of file. If I request with range in headers using just_audio then my audio file is the same duration in any url

kaliz
13 Mar, 2023, 09:59

Appwrite server use Transfer-Encoding: chunked in headers

kaliz
13 Mar, 2023, 10:02

Just mount modified file in first appwrite container or every appwrite container in docker-compose file

Drake
13 Mar, 2023, 13:22

The appwrite container should be enough

Drake
13 Mar, 2023, 13:25

How are you getting the duration?

kaliz
13 Mar, 2023, 13:28

Using durationStream

kaliz
13 Mar, 2023, 13:28

But with file uploaded to appwrite server can not get duration

Drake
13 Mar, 2023, 13:32

And are you testing on web?

kaliz
13 Mar, 2023, 13:33

Mobile only

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more