Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/video_player_avplay/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.7.5
* Fix the issue of subtitles remaining longer than their end time.

## 0.7.4
* Update plusplayer
1. [DASH] Fix this issue of audio switching not working in the dash video stream.
Expand Down
2 changes: 1 addition & 1 deletion packages/video_player_avplay/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ To use this package, add `video_player_avplay` as a dependency in your `pubspec.

```yaml
dependencies:
video_player_avplay: ^0.7.4
video_player_avplay: ^0.7.5
```

Then you can import `video_player_avplay` in your Dart code:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ class VideoPlayerTizen extends VideoPlayerPlatform {
return VideoEvent(
eventType: VideoEventType.subtitleUpdate,
text: map['text']! as String,
textDuration: map['duration'] as int?,
subtitleAttributes: map['attributes']! as List<dynamic>,
);
case 'isPlayingStateUpdate':
Expand Down
18 changes: 14 additions & 4 deletions packages/video_player_avplay/lib/video_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ class VideoPlayerValue {
return aspectRatio;
}

/// Returns the [Caption] that should be displayed based on the current [position].
/// If the value of [caption.end] has greater than the current [position], this will be a [Caption.none] object.
/// Only used for [copyWith].
Caption get _currentCaption {
return position > caption.end ? Caption.none : caption;
}

/// Returns a new instance that has the same values as this current instance,
/// except for any overrides passed in as arguments to [copyWidth].
VideoPlayerValue copyWith({
Expand All @@ -206,7 +213,7 @@ class VideoPlayerValue {
duration: duration ?? this.duration,
size: size ?? this.size,
position: position ?? this.position,
caption: caption ?? this.caption,
caption: caption ?? _currentCaption,
captionOffset: captionOffset ?? this.captionOffset,
tracks: tracks ?? this.tracks,
buffered: buffered ?? this.buffered,
Expand Down Expand Up @@ -594,7 +601,7 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
// we use pause() and seekTo() to ensure the platform stops playing
// and seeks to the last frame of the video.
pause().then((void pauseResult) => seekTo(value.duration.end));
value = value.copyWith(isCompleted: true);
value = value.copyWith(isCompleted: true, caption: Caption.none);
_durationTimer?.cancel();
case VideoEventType.bufferingUpdate:
value = value.copyWith(buffered: event.buffered);
Expand All @@ -607,10 +614,13 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
SubtitleAttribute.fromEventSubtitleAttrList(
event.subtitleAttributes,
);
final Duration textDuration = event.textDuration == 0
? Duration.zero
: Duration(milliseconds: event.textDuration!);
final Caption caption = Caption(
number: 0,
start: value.position,
end: value.position + (event.duration?.end ?? Duration.zero),
end: value.position + textDuration,
text: event.text ?? '',
subtitleAttributes: subtitleAttributes,
);
Expand Down Expand Up @@ -1125,7 +1135,7 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
/// [Caption].
Caption _getCaptionAt(Duration position) {
if (_closedCaptionFile == null) {
return value.caption;
return position > value.caption.end ? Caption.none : value.caption;
}

final Duration delayedPosition = position + value.captionOffset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ class VideoEvent {
this.size,
this.buffered,
this.text,
this.textDuration,
this.isPlaying,
this.subtitleAttributes,
this.adInfo,
Expand Down Expand Up @@ -583,6 +584,11 @@ class VideoEvent {
/// Only used if [eventType] is [VideoEventType.subtitleUpdate].
final String? text;

/// The duration of text
///
/// Only used if [eventType] is [VideoEventType.subtitleUpdate].
final int? textDuration;

/// Whether the video is currently playing.
///
/// Only used if [eventType] is [VideoEventType.isPlayingStateUpdate].
Expand All @@ -606,6 +612,7 @@ class VideoEvent {
size == other.size &&
buffered == other.buffered &&
text == other.text &&
textDuration == other.textDuration &&
isPlaying == other.isPlaying &&
subtitleAttributes == other.subtitleAttributes &&
adInfo == other.adInfo;
Expand All @@ -618,6 +625,7 @@ class VideoEvent {
size.hashCode ^
buffered.hashCode ^
text.hashCode ^
textDuration.hashCode ^
isPlaying.hashCode ^
subtitleAttributes.hashCode ^
adInfo.hashCode;
Expand Down
2 changes: 1 addition & 1 deletion packages/video_player_avplay/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: video_player_avplay
description: Flutter plugin for displaying inline video on Tizen TV devices.
homepage: https://github.com/flutter-tizen/plugins
repository: https://github.com/flutter-tizen/plugins/tree/master/packages/video_player_avplay
version: 0.7.4
version: 0.7.5

environment:
sdk: ">=3.1.0 <4.0.0"
Expand Down