Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/crazelu/subtitle_player
A Flutter package for synchronizing subtitles with video and audio playback.
https://github.com/crazelu/subtitle_player
dart dartlang flutter lrc lrc-parser srt-subtitles subrip subtitle-conversion subtitles subtitles-parsing webvtt webvtt-parser
Last synced: about 1 month ago
JSON representation
A Flutter package for synchronizing subtitles with video and audio playback.
- Host: GitHub
- URL: https://github.com/crazelu/subtitle_player
- Owner: Crazelu
- License: mit
- Created: 2024-04-13T23:52:49.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-04-15T23:05:08.000Z (7 months ago)
- Last Synced: 2024-04-24T07:25:37.856Z (7 months ago)
- Topics: dart, dartlang, flutter, lrc, lrc-parser, srt-subtitles, subrip, subtitle-conversion, subtitles, subtitles-parsing, webvtt, webvtt-parser
- Language: Dart
- Homepage:
- Size: 22.4 MB
- Stars: 12
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Subtitle Player
A Flutter package for synchronizing subtitles with video and audio playback.## Features 📦
- [x] Load SubRip, WebVTT and LRC subtitles
- [x] Play, pause and seek support
- [x] Adjust playback speed## Install 🚀
In the `pubspec.yaml` of your flutter project, add the `subtitle_player` dependency:
```yaml
dependencies:
subtitle_player:
git:
url: https://github.com/Crazelu/subtitle_player.git
```## Import the package in your project 📥
```dart
import 'package:subtitle_player/subtitle_player.dart';
```## Usage 🏗️
Create a `SubtitleController` and load a subtitle file
```dart
final subtitleController = SubtitleController();
subtitleController.loadSubtitle(Subtitle.fromWebVTT(content));
```Start playing subtitle with your audio/video
```dart
subtitleController.play();
```Subscribe to `SubtitleController` for changes using `ValuelistenableBuilder`, `ListenableBuilder` or `AnimatedBuilder`
```dart
// From the video player exampleAlign(
alignment: Alignment.bottomCenter,
child: ValueListenableBuilder(
valueListenable: _subtitleController,
builder: (context, subtitleValue, _) {
if (subtitleValue.currentSubtitle.isEmpty) {
return const SizedBox.shrink();
}
return Container(
constraints: BoxConstraints(
maxWidth: (MediaQuery.sizeOf(context).height *
_controller.value.aspectRatio) *
0.5),
padding: const EdgeInsets.all(4),
margin: const EdgeInsets.only(bottom: 8),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4),
color: Colors.black.withOpacity(0.65),
),
child: Text(
subtitleValue.currentSubtitle,
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 12,
color: Colors.white,
),
),
);
},
),
)
```Check the [example project](https://github.com/Crazelu/subtitle_player/tree/main/example) for more detailed usage examples both for video and audio playing.
## Demo 📷
## Contributions 🫱🏾🫲🏼
Feel free to contribute to this project.
If you find a bug or want a feature, but don't know how to fix/implement it, please fill an [issue](https://github.com/Crazelu/subtitle_player/issues).
If you fixed a bug or implemented a feature, please send a [pull request](https://github.com/Crazelu/subtitle_player/pulls).