diff --git a/example/lib/main.dart b/example/lib/main.dart index 1809909b..a7f49a67 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -13,7 +13,11 @@ class DartVLC extends StatefulWidget { } class _DartVLCState extends State { - Player? player; + Player? player = Player( + id: 0, + videoWidth: 480, + videoHeight: 360, + ); MediaType mediaType = MediaType.file; CurrentState current = new CurrentState(); PositionState position = new PositionState(); @@ -22,35 +26,35 @@ class _DartVLCState extends State { List medias = []; List devices = []; TextEditingController controller = new TextEditingController(); - Media? metasMedia; TextEditingController metasController = new TextEditingController(); + Media? metasMedia; @override - void didChangeDependencies() async { - super.didChangeDependencies(); + void initState() { + super.initState(); if (this.mounted) { - this.player = await Player.create( - id: 0, - videoWidth: 480, - videoHeight: 360, - ); - this.player?.currentStream?.listen((current) { + this.player?.currentStream.listen((current) { this.setState(() => this.current = current); }); - this.player?.positionStream?.listen((position) { + this.player?.positionStream.listen((position) { this.setState(() => this.position = position); }); - this.player?.playbackStream?.listen((playback) { + this.player?.playbackStream.listen((playback) { this.setState(() => this.playback = playback); }); - this.player?.generateStream?.listen((general) { + this.player?.generateStream.listen((general) { this.setState(() => this.general = general); }); - this.devices = await Devices.all; - this.setState(() {}); } } + @override + Future didChangeDependencies() async { + super.didChangeDependencies(); + this.devices = await Devices.all; + this.setState(() {}); + } + @override Widget build(BuildContext context) { return MaterialApp( @@ -73,8 +77,8 @@ class _DartVLCState extends State { elevation: 2.0, child: Video( playerId: 0, - width: 480, - height: 320, + width: 640, + height: 480, volumeThumbColor: Colors.blue, volumeActiveColor: Colors.blue, ),