I am trying to create a youtube mp3 downloader (android app) with flutter using the youtube_explode_dart package. I successfully download the mp3 file to the phone but the problem is after playing the whole file once, it cannot be played again. There is an exception tho. Songs that are more or less a minute long are downloaded and be played perfectly fine.
Here is my code snippet for getting the youtube stream and creating and saving the mp3 file:
var yt = YoutubeExplode();
var manifest = await yt.videos.streamsClient.getManifest(url);
var streamInfo = manifest.audioOnly.withHighestBitrate();
var stream = yt.videos.streamsClient.get(streamInfo);
var file = File(finalDir + title + ".mp3");
file.create();
var fileStream = file.openWrite();
await stream.pipe(fileStream);
await fileStream.flush();
await fileStream.close();
yt.close();
What could have been my mistake?