Home > OS >  How to get duration of an audio file given only its url
How to get duration of an audio file given only its url

Time:11-18

I have an mp3 audio file located under 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.

CodePudding user response:

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: )
  • Related