how to get only the audio duration from it's url

Issue

I have audio with this link:

https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3

how can I get its duration in my flutter app without getting the whole audio ?

Just it’s length duration? I want the quickest possible way to get it.

Thank you.

Solution

You could go with the just_audio package.

import 'package:just_audio/just_audio.dart';

final player = AudioPlayer();                   // Create a player
final duration = await player.setUrl(           // Load a URL
    'https://example.com/bar.mp3');             // Schemes: (https: | file: | asset: )

Answered By – jraufeisen

Answer Checked By – Willingham (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *