The Subtitle Wrapper package provides an easy way to display subtitles for videos using the VLC player in a Flutter application. It supports multiple subtitle formats and allows for dynamic subtitle delay adjustments.
- Display subtitles from SRT and WebVTT files.
- Adjust subtitle delay dynamically.
- Customize subtitle text style.
Add the following dependency to your pubspec.yaml
:
-
Initialize the Subtitle Controller:
Create an instance of
SubtitleController
with the desired subtitle URL and type.SubtitleController subtitleController = SubtitleController( subtitleUrl: 'https://example.com/subtitles.srt', subtitleType: SubtitleType.srt, subtitleDecoder: SubtitleDecoder.utf8, );
-
Set up the VLC Player:
Initialize the
VlcPlayerController
with the video URL.VlcPlayerController vlcPlayerController = VlcPlayerController.network( 'http://example.com/video.mp4', autoPlay: true, );
-
Use the Subtitles Wrapper:
Wrap your VLC player with the
SubtitleWrapper
widget to display subtitles.startLine: 7 endLine: 48
-
Adjust Subtitles Delay:
Use the
addSubtitleDelay
andremoveSubtitleDelay
methods to adjust the subtitle delay in milliseconds.startLine: 72 endLine: 86
Here's a simple example of how to integrate the subtitle wrapper in your Flutter app:
-
For more details on the
SubtitleController
and its methods, refer to the code snippet: lib/subtitle_controller.dart -
For the complete example setup, see: example/lib/main.dart