dart_vlc 0.0.3
dart_vlc: ^0.0.3 copied to clipboard
A media playback library for Dart & Flutter. Based on libVLC & libVLC++.
dart_vlc
Bringing power of VLC to Flutter & Dart apps on Windows & Linux
Installation #
dependencies:
...
dart_vlc: ^0.0.1

Documentation #
Create a new Player instance.
Player player = await Player.create(id: 69420);
Create a single Media.
Media media0 = await Media.file(
new File('C:/music.mp3')
);
Media media1 = await Media.network(
'https://www.example.com/music.aac'
);
Media media2 = await Media.asset(
'assets/music.ogg'
);
Create a list of Medias using Playlist.
Playlist playlist = new Playlist(
medias: [
await Media.file(new File('C:/music.mp3')),
await Media.asset('assets/music.ogg'),
await Media.network('https://www.example.com/music.aac'),
],
);
Open Media or Playlist into a Player instance.
player.open(
new Playlist(
medias: [
await Media.file(new File('C:/music0.mp3')),
await Media.file(new File('C:/music1.mp3')),
await Media.file(new File('C:/music2.mp3')),
],
),
autoStart: true, //default
);
Control playback.
player.play();
player.seek(Duration(seconds: 30));
player.pause();
player.playOrPause();
player.stop();
Manipulate Playlist.
player.add(
await Media.file(new File('C:/music0.mp3')),
);
player.remove(4);
player.insert(
2,
await Media.file(new File('C:/music0.mp3')),
);
player.move(0, 4);
Set playback volume & rate.
player.setVolume(0.5);
player.setRate(1.25);
Get & change playback Device.
List<Device> devices = await Devices.all;
player.setDevice(
devices[0],
);
Retrieve metadata of Media.
Media media = await Media.network(
'https://www.example.com/media.mp3',
parse: true,
timeout: new Duration(seconds: 10),
);
Map<String, String> metas = media.metas;
Listen to playback events.
(Same can be retrieved directly from Player instance without having to rely on stream).
player.currentStream.listen((CurrentState state) {
state.index;
state.media;
state.medias;
state.isPlaylist;
});
player.positionStream.listen((PositionState state) {
state.position;
state.duration;
});
player.playbackStream.listen((PlaybackState state) {
state.isPlaying;
state.isSeekable;
state.isCompleted;
});
player.generalStream.listen((GeneralState state) {
state.volume;
state.rate;
});
NOTE: For using this plugin on Linux, you must have libVLC installed. On debian based distros, run:
sudo apt-get install libvlc-dev
Support #
Consider supporting the project by either/and:
- Starring the repository, to get this hardwork noticed.
- Buying me a coffee.
Example #
You can see an example project here.
Windows
Progress #
Done
Mediaplayback fromFile.Mediaplayback from network.Mediaplayback from assets.play/pause/playOrPause/stop.- Multiple
Playerinstances. Playlist.next/back/jumpfor playlists.setVolume.setRate.seek.- Events.
- Automatic fetching of headers, libs & shared libraries.
- Changing VLC version from CMake.
- Event streams.
Player.currentStateindex: Index of current media inPlaylist.medias: List of all openedMedias.media: Currently playingMedia.isPlaylist: Whether a singleMediais loaded or aPlaylist.
Player.positionStateposition: Position of currently playing media inDuration.duration: Position of currently playing media inDuration.
Player.playbackStateisPlaying.isSeekable.isCompleted.
Player.generalStatevolume: Volume of currentPlayerinstance.rate: Rate of currentPlayerinstance.
add/insert/remove/moveMediainsidePlaylistduring playback.- Device enumeration & changing.
- Retrieving
Metaof aMedia.
Under progress (irrespective of order)...
- Embedding video inside the Flutter window.
- Make things more efficient.
- Supporting live streaming links.
- Supporting native volume control/lock screen notifications.
- FFI version of the library for plain Dart applications.
- Bringing project on other platforms like Android/iOS.
Contributions #
The code in the project is nicely arranged (I guess), I have added comments wherever I felt necessary.
Contributions to the project are open, it will be appreciated if you discuss the bug-fix/feature-addition in the issues first.
License #
Copyright (C) 2021, Hitesh Kumar Saini.
This library & work under this repository is licensed under GNU Lesser General Public License v2.1.
Acknowledgements #
Thanks to following people for supporing the project:
- @DomingoMG
- Salman Aljabri
Spoilers #
Currenty video playback is also supported out of the box, but it doesnt show inside Flutter window.
Vision #
There aren't any media (audio or video) playback libraries for Flutter on Windows/Linux yet. So, this project is all about that. As one might be already aware, VLC is one of the best media playback tools out there.
So, now you can use it to play audio or video [WIP] files from Flutter Desktop app.
The API style of this project is highly influenced by assets_audio_player due to its completeness. This project will serve as a base to add Windows & Linux support to already existing audio playback libraries like just_audio and assets_audio_player.
Although, the mentioned repositories above are for audio playback, video playback is also a part of consideration for this project.
Thanks to the VideoLAN team for creating libVLC & libVLC++. Really great guys really great at their work.