vlc_flutter

Creator: coderz1093

Last updated:

0 purchases

vlc_flutter Image
vlc_flutter Images

Languages

Categories

Add to Cart

Description:

vlc flutter

vlc-flutter #
This is a Flutter wrapper plugin for libvlc.See their website.
Todo:

✅ Android
✅ iOS

Usage #
dependencies:
vlc_flutter: ^0.0.2
copied to clipboard
import 'package:vlc_flutter/vlcplayer.dart';
copied to clipboard
Create VLCController:
// "-vvv" option
// print as detailed a log as possible for debugging purposes
VLCController _controller = VLCController(args:["-vvv"]);
copied to clipboard
Create a view for playback:
AspectRatio(
aspectRatio: 16/9,
child: VLCVideoWidget(
controller: _controller,
),
)
copied to clipboard
Play video according to uri:
ElevatedButton(
child: Text("play"),
onPressed: () async {
await _controller.setDataSource(uri:"rtmp://58.200.131.2:1935/livetv/natlgeo");
_controller.play();
}),
copied to clipboard
Or just use the play:
_controller.play(uri:"rtmp://58.200.131.2:1935/livetv/natlgeo");
copied to clipboard
Play local resources:
_controller.play(path:"/sdcard/test/test.mp4");
copied to clipboard
Listening to the status of the player:
_controller.onPlayerState.listen((event) {
debugPrint("=*= $event =*=");
});
copied to clipboard
Listening to player events:
_controller.onEvent.listen((event) {
if(event.type == EventType.PositionChanged){
debugPrint("==[${event.positionChanged}]==");
}
});
copied to clipboard
Add subtitles:
// Loading local subtitles
await _controller.addSlave(path: "/sdcard/test/Test.srt");
// Set the position of the subtitles
_controller.setVideoTitleDisplay(Position.Bottom, 1000);
copied to clipboard
Recorded video:
// Specify a directory and start recording
_controller.startRecord("/sdcard/test/");
// Stop Recording
_controller.stopRecord();
copied to clipboard
Don't forget to add network permissions to the AndroidManifest.xml to play network resources:
<uses-permission android:name="android.permission.INTERNET" />
copied to clipboard
If you need to record video, you may also need the following permissions:(These are dangerous permissions on Android 6.0 and above, so you may also need the flutter_easy_permission plugin)
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
copied to clipboard
Example #
class _MyAppState extends State<MyApp> {
VLCController _controller = VLCController();

@override
void initState() {
super.initState();

_controller.onEvent.listen((event) {
if(event.type == EventType.PositionChanged){
debugPrint("==[${event.positionChanged}]==");
}
});
}

@override
void dispose() {
_controller.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('VLCPlayer Plugin example'),
),
body: Column(
mainAxisSize: MainAxisSize.min,
children: [
AspectRatio(
aspectRatio: 16/9,
child: VLCVideoWidget(
controller: _controller,
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
ElevatedButton(
child: Text("play"),
onPressed: () async {
await _controller.setDataSource(
uri: "rtmp://58.200.131.2:1935/livetv/natlgeo");
_controller.play();
}),
ElevatedButton(
child: Text("pause"),
onPressed: () {
_controller.pause();
}),
ElevatedButton(
child: Text("stop"),
onPressed: () {
_controller.stop();
}),
ElevatedButton(
child: Text("startRecord"),
onPressed: () {
_controller.startRecord("/sdcard/test/");
}),

ElevatedButton(
child: Text("stopRecord"),
onPressed: () {
_controller.stopRecord();
})
],
)
],
),
),
);
}
}
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.