diff --git a/packages/video_player/video_player/CHANGELOG.md b/packages/video_player/video_player/CHANGELOG.md index 22a4bc0ed80..9892265b485 100644 --- a/packages/video_player/video_player/CHANGELOG.md +++ b/packages/video_player/video_player/CHANGELOG.md @@ -1,6 +1,7 @@ -## NEXT +## 2.9.3 * Updates minimum supported SDK version to Flutter 3.22/Dart 3.4. +* Fixes mechanism to detect identifier in multi-line WebVTT captions. ## 2.9.2 diff --git a/packages/video_player/video_player/lib/src/web_vtt.dart b/packages/video_player/video_player/lib/src/web_vtt.dart index 5527e62b69f..9f6a7452721 100644 --- a/packages/video_player/video_player/lib/src/web_vtt.dart +++ b/packages/video_player/video_player/lib/src/web_vtt.dart @@ -49,8 +49,9 @@ List _parseCaptionsFromWebVTTString(String file) { continue; } - // Caption has header - final bool hasHeader = captionLines.length > 2; + // Caption has header / identifier + // See: https://www.w3.org/TR/webvtt1/#webvtt-cue-identifier for valid cue identifier + final bool hasHeader = !captionLines[0].contains(_webVTTArrow); if (hasHeader) { final int? tryParseCaptionNumber = int.tryParse(captionLines[0]); if (tryParseCaptionNumber != null) { diff --git a/packages/video_player/video_player/pubspec.yaml b/packages/video_player/video_player/pubspec.yaml index 525d8c27497..7c5e7980db4 100644 --- a/packages/video_player/video_player/pubspec.yaml +++ b/packages/video_player/video_player/pubspec.yaml @@ -3,7 +3,7 @@ description: Flutter plugin for displaying inline video with other Flutter widgets on Android, iOS, and web. repository: https://github.com/flutter/packages/tree/main/packages/video_player/video_player issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22 -version: 2.9.2 +version: 2.9.3 environment: sdk: ^3.4.0 diff --git a/packages/video_player/video_player/test/web_vtt_test.dart b/packages/video_player/video_player/test/web_vtt_test.dart index dac6f49e319..8a356387942 100644 --- a/packages/video_player/video_player/test/web_vtt_test.dart +++ b/packages/video_player/video_player/test/web_vtt_test.dart @@ -24,6 +24,21 @@ void main() { parsedFile = WebVTTCaptionFile(_valid_vtt_with_multiline); expect(parsedFile.captions.length, 1); + expect(parsedFile.captions[0].number, 2); + expect(parsedFile.captions[0].start, + const Duration(seconds: 2, milliseconds: 800)); + expect(parsedFile.captions[0].end, + const Duration(seconds: 3, milliseconds: 283)); + expect(parsedFile.captions[0].text, + '— It will perforate your stomach.\n— You could die.'); + }); + + test('with Multiline without identifier', () { + parsedFile = + WebVTTCaptionFile(_valid_vtt_with_multiline_without_identifier); + expect(parsedFile.captions.length, 1); + + expect(parsedFile.captions[0].number, 1); expect(parsedFile.captions[0].start, const Duration(seconds: 2, milliseconds: 800)); expect(parsedFile.captions[0].end, @@ -147,6 +162,15 @@ WEBVTT '''; +const String _valid_vtt_with_multiline_without_identifier = ''' +WEBVTT + +00:02.800 --> 00:03.283 +— It will perforate your stomach. +— You could die. + +'''; + /// See https://www.w3.org/TR/webvtt1/#styling const String _valid_vtt_with_styles = ''' WEBVTT