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();
}
})
]));
}
}