Skip to content

Commit 934a113

Browse files
authored
Merge pull request #2 from Crazelu/feat/duration-sync
FEAT: Duration sync
2 parents fc7e2c3 + 5d2ee50 commit 934a113

File tree

19 files changed

+382
-48
lines changed

19 files changed

+382
-48
lines changed

.github/workflows/ci.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
env:
10+
flutter_version: "3.29.3"
11+
java_version: "17.x"
12+
13+
jobs:
14+
format-and-lint:
15+
name: Linting and tests
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v1
19+
- uses: actions/setup-java@v1
20+
with:
21+
java-version: ${{ env.java_version }}
22+
- name: Cache Flutter dependencies
23+
uses: actions/cache@v3
24+
with:
25+
path: /opt/hostedtoolcache/flutter
26+
key: ${{ runner.OS }}-flutter-install-cache-${{ env.flutter_version }}
27+
- uses: subosito/flutter-action@v2
28+
with:
29+
flutter-version: ${{ env.flutter_version }}
30+
- name: Install dependencies
31+
run: flutter pub get
32+
- name: Format code
33+
run: dart format . --set-exit-if-changed
34+
- name: Lint analysis
35+
run: flutter analyze --no-pub
36+
- name: Run tests
37+
run: flutter test --coverage
38+
- name: Upload coverage to codecov
39+
uses: codecov/codecov-action@v4.0.1
40+
with:
41+
file: ./coverage/lcov.info
42+
token: ${{ secrets.CODECOV_TOKEN }}

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
## 0.0.1
1+
## 1.0.0
22

3-
- Initial pre-release version.
3+
- Initial release version.

README.md

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
11
# Subtitle Player
2-
A Flutter package for synchronizing subtitles with video and audio playback.
2+
3+
<p align="center">
4+
<a href="https://pub.dev/packages/subtitle_player/score"><img src="https://img.shields.io/pub/likes/subtitle_player" alt="likes"></a>
5+
<a href="https://pub.dev/packages/subtitle_player/score"><img src="https://img.shields.io/pub/points/subtitle_player" alt="pub points"></a>
6+
<a href="https://codecov.io/gh/crazelu/subtitle_player"><img src="https://codecov.io/gh/crazelu/subtitle_player/graph/badge.svg" alt="code coverage"/></a>
7+
</p>
8+
9+
10+
A library for synchronizing subtitles with video and audio playback.
11+
312

413
## Features 📦
514

6-
- [x] Load SubRip, WebVTT and LRC subtitles
15+
- [x] Load SubRip, WebVTT and LRC formats
716
- [x] Play, pause and seek support
817
- [x] Adjust playback speed
918

1019
## Install 🚀
1120

12-
In the `pubspec.yaml` of your flutter project, add the `subtitle_player` dependency:
21+
In the `pubspec.yaml` of your Flutter/Dart project, add the `subtitle_player` dependency:
1322

1423
```yaml
1524
dependencies:
16-
subtitle_player:
17-
git:
18-
url: https://github.com/Crazelu/subtitle_player.git
25+
subtitle_player: ^1.0.0
1926
```
2027
2128
## Import the package in your project 📥
@@ -77,6 +84,21 @@ Subscribe to `SubtitleController` for changes using `ValuelistenableBuilder`, `L
7784
)
7885
```
7986

87+
Alternatively, you can attach a listener to the audio/video playback's position and call the `sync` method whenever the position changes.
88+
89+
```dart
90+
// Example with JustAudio
91+
92+
final player = AudioPlayer();
93+
final positionStream = player.createPositionStream();
94+
95+
final streamSubscription = positionStream.listen((position) {
96+
subtitleController.sync(position);
97+
});
98+
99+
// make sure to cancel the stream subscription when ready to release resources
100+
```
101+
80102
Check the [example project](https://github.com/Crazelu/subtitle_player/tree/main/example) for more detailed usage examples both for video and audio playing.
81103

82104
## Demo 📷

example/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
*.swp
66
.DS_Store
77
.atom/
8+
.build/
89
.buildlog/
910
.history
1011
.svn/
12+
.swiftpm/
1113
migrate_working_dir/
1214

1315
# IntelliJ related

example/android/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ GeneratedPluginRegistrant.java
1111
key.properties
1212
**/*.keystore
1313
**/*.jks
14+
app/.cxx/

example/android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ if (flutterVersionName == null) {
2525
android {
2626
namespace "com.example.example"
2727
compileSdk flutter.compileSdkVersion
28-
ndkVersion flutter.ndkVersion
28+
ndkVersion "27.0.12077973"
2929

3030
compileOptions {
3131
sourceCompatibility JavaVersion.VERSION_1_8

example/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip

example/android/settings.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ pluginManagement {
1919

2020
plugins {
2121
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
22-
id "com.android.application" version "7.3.0" apply false
23-
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
22+
id "com.android.application" version "8.7.1" apply false
23+
id "org.jetbrains.kotlin.android" version "1.9.0" apply false
2424
}
2525

2626
include ":app"

example/ios/Podfile.lock

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ PODS:
44
- Flutter (1.0.0)
55
- just_audio (0.0.1):
66
- Flutter
7+
- FlutterMacOS
78
- path_provider_foundation (0.0.1):
89
- Flutter
910
- FlutterMacOS
@@ -14,7 +15,7 @@ PODS:
1415
DEPENDENCIES:
1516
- audio_session (from `.symlinks/plugins/audio_session/ios`)
1617
- Flutter (from `Flutter`)
17-
- just_audio (from `.symlinks/plugins/just_audio/ios`)
18+
- just_audio (from `.symlinks/plugins/just_audio/darwin`)
1819
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
1920
- video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/darwin`)
2021

@@ -24,19 +25,19 @@ EXTERNAL SOURCES:
2425
Flutter:
2526
:path: Flutter
2627
just_audio:
27-
:path: ".symlinks/plugins/just_audio/ios"
28+
:path: ".symlinks/plugins/just_audio/darwin"
2829
path_provider_foundation:
2930
:path: ".symlinks/plugins/path_provider_foundation/darwin"
3031
video_player_avfoundation:
3132
:path: ".symlinks/plugins/video_player_avfoundation/darwin"
3233

3334
SPEC CHECKSUMS:
34-
audio_session: 088d2483ebd1dc43f51d253d4a1c517d9a2e7207
35+
audio_session: 9bb7f6c970f21241b19f5a3658097ae459681ba0
3536
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
36-
just_audio: baa7252489dbcf47a4c7cc9ca663e9661c99aafa
37-
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
38-
video_player_avfoundation: 2b4384f3b157206b5e150a0083cdc0c905d260d3
37+
just_audio: 4e391f57b79cad2b0674030a00453ca5ce817eed
38+
path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564
39+
video_player_avfoundation: 2cef49524dd1f16c5300b9cd6efd9611ce03639b
3940

4041
PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796
4142

42-
COCOAPODS: 1.14.3
43+
COCOAPODS: 1.16.2

example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
ignoresPersistentStateOnLaunch = "NO"
6060
debugDocumentVersioning = "YES"
6161
debugServiceExtension = "internal"
62+
enableGPUValidationMode = "1"
6263
allowLocationSimulation = "YES">
6364
<BuildableProductRunnable
6465
runnableDebuggingMode = "0">

0 commit comments

Comments
 (0)