我正在建立一个应用程序,当用户点击按钮,它会转到画廊,并选择画廊中的任何视频,然后返回到应用程序的主屏幕,并自动播放视频。
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Image App Demo',
theme: ThemeData(
primaryColor: Color(0xff476cfb),
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
File _imageFile;
Future getVideo() async{
File image;
image=await ImagePicker.pickVideo(source: ImageSource.gallery);
setState(() {
_imageFile=image;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Image Upload"),
),
body: ListView(
children: <Widget>[
Center(
child: Column(
children: <Widget>[
SizedBox(height: 10.0,),
RaisedButton(
child: Text("Video"),
onPressed: (){
getVideo();
},
),
],
),
)
],
}
2条答案
按热度按时间i2byvkas1#
使用video player显示视频
ni65a41a2#
你可以从image_picker基于n图像选择器的应答示例中使用这个小部件
//如何将视频传递到预览