Flutter VLC Player with options

import 'package:flutter/material.dart';
import 'package:flutter_vlc_player/flutter_vlc_player.dart';
class Home extends StatefulWidget { @override _ExampleVideoState createState() => _ExampleVideoState();
}
class _ExampleVideoState extends State<Home> { final VlcPlayerController controller = new VlcPlayerController.network(url); @override Widget build(BuildContext context) { return Scaffold( body: SizedBox( height: 100, width: 40, child: new VlcPlayer( aspectRatio: 16 / 9, options : VlcPlayeroptions(), controller: controller, placeholder: Center(child: CircularProgressIndicator()), ) ) ); }
} 

this is my example where video is playing good, but i need to add options to it like play and pause, "options" is not working

i need to add play and pause button on vlc player in flutter app

1

2 Answers

Add a widget that sends play/pause through the controller class. Check out the other available methods too for the VlcPlayerController class.

ElevatedButton.icon( onPressed: () => controller.pause(), icon: const Icon(Icons.pause), label: const Text('Pause'))
0
import 'package:flutter/material.dart';
import 'package:flutter_vlc_player/flutter_vlc_player.dart';
class Home extends StatefulWidget { @override _ExampleVideoState createState() => _ExampleVideoState();
}
class _ExampleVideoState extends State<Home> { late bool _isplaying = true; final VlcPlayerController controller = VlcPlayerController.network( "url", hwAcc: HwAcc.auto, options: VlcPlayerOptions(), ); @override Widget build(BuildContext context) { return Scaffold( body: Column(children: <Widget>[ SizedBox( width: MediaQuery.of(context).size.width, height: 225, child: VlcPlayer( aspectRatio: 16 / 9, controller: controller, placeholder: const Center(child: CircularProgressIndicator()), ), ), Container( child: Row(mainAxisAlignment: MainAxisAlignment.center, children: [ if (_isplaying) TextButton( onPressed: () { controller.pause(); setState(() { _isplaying = false; }); }, child: const Icon( Icons.play_arrow, size: 50, ), ) else TextButton( onPressed: () { setState(() { _isplaying = true; controller.play(); }); }, child: Icon( Icons.pause, size: 50, ), ), ]), ),] ); }
}

This is how i get it work done

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like