Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[video_player] fixed misleading size and aspect ratio documentation #3668

Merged
merged 7 commits into from
Mar 10, 2021
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
4 changes: 4 additions & 0 deletions packages/video_player/video_player/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.0.2

* Fix `VideoPlayerValue` size and aspect ratio documentation

## 2.0.1

* Remove the deprecated API "exoPlayer.setAudioAttributes".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ class Caption {
///
/// This is not recommended for direct use unless you are writing a parser for
/// a new closed captioning file type.
const Caption(
{required this.number,
required this.start,
required this.end,
required this.text});
const Caption({
required this.number,
required this.start,
required this.end,
required this.text,
});

/// The number that this caption was assigned.
final int number;
Expand All @@ -52,8 +53,12 @@ class Caption {

/// A no caption object. This is a caption with [start] and [end] durations of zero,
/// and an empty [text] string.
static const Caption none =
Caption(number: 0, start: Duration.zero, end: Duration.zero, text: '');
static const Caption none = Caption(
number: 0,
start: Duration.zero,
end: Duration.zero,
text: '',
);

@override
String toString() {
Expand Down
12 changes: 7 additions & 5 deletions packages/video_player/video_player/lib/video_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,10 @@ class VideoPlayerValue {

/// A description of the error if present.
///
/// If [hasError] is false this is [null].
/// If [hasError] is false this is `null`.
final String? errorDescription;

/// The [size] of the currently loaded video.
///
/// Is null when [initialized] is false.
final Size size;

/// Indicates whether or not the video has been loaded and is ready to play.
Expand All @@ -102,8 +100,12 @@ class VideoPlayerValue {
/// [errorDescription] should have information about the problem.
bool get hasError => errorDescription != null;

/// Returns [size.width] / [size.height] when size is non-null, or `1.0.` when
/// size is null or the aspect ratio would be less than or equal to 0.0.
/// Returns [size.width] / [size.height].
///
/// Will return `1.0` if:
/// * [isInitialized] is `false`
/// * [size.width], or [size.height] is equal to `0.0`
/// * aspect ratio would be less than or equal to `0.0`
double get aspectRatio {
if (!isInitialized || size.width == 0 || size.height == 0) {
return 1.0;
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
@@ -1,7 +1,7 @@
name: video_player
description: Flutter plugin for displaying inline video with other Flutter
widgets on Android, iOS, and web.
version: 2.0.1
version: 2.0.2
homepage: https://github.com/flutter/plugins/tree/master/packages/video_player/video_player

flutter:
Expand Down