1

I cannot find a way to do this with their docs, I want to load all video files into playlist but i cannot find a way to call it. How can i call all the video files in "${directory?.path}/$fileName"; and put it into a playlist.

import 'package:path_provider/path_provider.dart';

class Utils {
 static Future<String> getFileUrl(String fileName) async {
final directory = await getExternalStorageDirectory();
return "${directory?.path}/$fileName";}}

Blockquote

import 'package:better_player/better_player.dart';
import 'package:flutter/material.dart';
import 'package:untitled/utili.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
  title: 'Flutter Demo',
  theme: ThemeData(
    primarySwatch: Colors.blue,
  ),
  home: MyHomePage(),
);
}
}

class MyHomePage extends StatelessWidget {
 @override
 Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(
      title: Text('Video Player'),
    ),
    body: Column(children: [
      FutureBuilder<String>(
          future: Utils.getFileUrl(directory?.path}/$fileName),
          builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
            if (snapshot.data != null) {
              return BetterPlayer.file(snapshot.data!);
            } else {
              return const SizedBox();
            }
          })
    ]));
    }
    }
GIN
  • 51
  • 6
  • Does [this Answer](https://stackoverflow.com/a/43164126/2057709) help you? The idea is that you build a list (Array) of file names/path and then reference that list for entries in your own "playlist". – VC.One May 05 '22 at 17:23
  • no idea how to make it work. still trying. – GIN May 06 '22 at 14:54

0 Answers0