Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Closed
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
5 changes: 5 additions & 0 deletions packages/video_player/video_player/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.10.12+5

* Added isDurationIndefinite to support indefinite streams
* Raised video_player_platform_interface in video_player to 2.1.1.

## 0.10.12+4

* Keep handling deprecated Android v1 classes for backward compatibility.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@ - (void)updatePlayingState {
_displayLink.paused = !_isPlaying;
}

- (bool)isDurationIndefinite {
return CMTIME_IS_INDEFINITE([[_player currentItem] duration]);
}

- (void)sendInitialized {
if (_eventSink && !_isInitialized) {
CGSize size = [self.player currentItem].presentationSize;
Expand All @@ -312,8 +316,9 @@ - (void)sendInitialized {
if (height == CGSizeZero.height && width == CGSizeZero.width) {
return;
}

// The player may be initialized but still needs to determine the duration.
if ([self duration] == 0) {
if ([self duration] == 0 && ![self isDurationIndefinite]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cyanglaz any hints on how to test cover this?

return;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/video_player/video_player/lib/video_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -757,12 +757,12 @@ class _VideoProgressIndicatorState extends State<VideoProgressIndicator> {
fit: StackFit.passthrough,
children: <Widget>[
LinearProgressIndicator(
value: maxBuffering / duration,
value: duration > 0 ? maxBuffering / duration : 0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to cover the crashy behavior with a test?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does duration 0 means it's indefinite? if so should we use null for value to show an indefinite progress indicator?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's 0 on iOS. Android returns different values

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have an indication on Android that it's indefinite? what does the progress bar show for indefinite streams on Android?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exoPlayer does have a isDynamic function on the Window. This is set to true when a Live stream is being played. I believe this would be the best solution. Link to the docs..

I could implement a VideoPlayerController().isDurationIndefinite getter that returns true when ExoPlayer returns true on the isDynamic getter on Android, and when isDurationIndefinite returns true on iOS?

valueColor: AlwaysStoppedAnimation<Color>(colors.bufferedColor),
backgroundColor: colors.backgroundColor,
),
LinearProgressIndicator(
value: position / duration,
value: duration > 0 ? position / duration : 0,
valueColor: AlwaysStoppedAnimation<Color>(colors.playedColor),
backgroundColor: Colors.transparent,
),
Expand Down
2 changes: 1 addition & 1 deletion packages/video_player/video_player/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Flutter plugin for displaying inline video with other Flutter
# 0.10.y+z is compatible with 1.0.0, if you land a breaking change bump
# the version to 2.0.0.
# See more details: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0
version: 0.10.12+4
version: 0.10.12+5
homepage: https://github.com/flutter/plugins/tree/master/packages/video_player/video_player

flutter:
Expand Down