Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[video_player_videohole] Add get duration API for live stream #643

Merged
merged 5 commits into from
Jan 3, 2024

Conversation

xiaowei-guan
Copy link
Contributor

@xiaowei-guan xiaowei-guan commented Dec 22, 2023

Live stream duration is different from common video duration.

  1. Live stream duration is a range, so we change duration variable from Duration to DurationRange, the DurationRange which include a start time and a end time.
  2. The duration of the live stream changes during playback, so need add a timer to get duration.

@xiaowei-guan xiaowei-guan marked this pull request as draft December 22, 2023 08:10
@xiaowei-guan xiaowei-guan marked this pull request as ready for review December 22, 2023 09:03
@@ -271,7 +276,7 @@ class VideoEvent {
/// Duration of the video.
///
/// Only used if [eventType] is [VideoEventType.initialized].
final Duration? duration;
final DurationRange? duration;
Copy link
Member

Choose a reason for hiding this comment

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

https://github.com/flutter/packages/blob/main/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart#L229
Can't we just keep Duration type and use the value of duration.second returned by mediaplayer?
The interface that returns DurationRange for stream play seems to be buffered. (https://github.com/flutter/packages/blob/main/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart#L244)
what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For live stream, the duration is a range which includes start time and end time.

 player_get_adaptive_streaming_info(player_, (void *)&live_duration_buff, PLAYER_ADAPTIVE_INFO_LIVE_DURATION);

When call seekTo, the time must be in the range, the start time is only used to judge. If remove start time, we might have seekTo issue.
I have tested seekTo for live stream, if we get live stream duration is [300, 500] and then call seekTo(200), the player just start with 300.

Copy link
Member

Choose a reason for hiding this comment

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

My worry is the change in interface. (I know, we have a separate interface from video_player_platform_interface.)

In my opinion..
When a user needs a seekTo point in valid range of streaming content, they can check the valid seekTo by taking the value from buffered rather than the duration value.
https://github.com/flutter/packages/blob/36a7b99381f85e86914e82c75fc7d9038ed96cca/packages/video_player/video_player_platform_interface/lib/video_player_platform_interface.dart#L241-L244

  /// Buffered parts of the video.
  ///
  /// Only used if [eventType] is [VideoEventType.bufferingUpdate].
  final List<DurationRange>? buffered;

Our int buffered is progress value of buffering. so we can change this API.
Of course, we don't necessarily have to follow the video_player_platform_interface, so this can be reconsidered later.

@hyue7 hyue7 merged commit e6446a4 into flutter-tizen:master Jan 3, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants