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

Conversation

@ditman
Copy link
Member

@ditman ditman commented Jun 5, 2020

Description

While testing the image_picker_web plugin, I noticed that video playback was a little bit flaky. This PR addresses some of the subtle bugs in the image_picker example app, video_player plugin and video_player_web implementation.

Related Issues

n/a

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • No, this is not a breaking change.

All changes are minor and independent, so no need to split this PR in several different ones. This all should be mergeable and publishable in parallel.

}

void setVolume(double value) {
if (value > 0.0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

might need to introduce a small epsilon when comparing float values

Copy link
Contributor

Choose a reason for hiding this comment

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

Or we make the muted property public so user can directly set mute instead of setting a 0.0 value.

Copy link
Member Author

@ditman ditman Jun 9, 2020

Choose a reason for hiding this comment

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

This "hatch" is only there so web users can do: setVolume(0.0) and get a "muted" player.

About making the muted property public: I agree, but I am not sure what the implications are for Android and iOS of that.

There's a huge API surface for the video element that is being hidden by the current platform API, and I'm not sure if it's because we want a very simple API, or because the API can't be extended for other platforms :/

For this PR I was only trying to make the selected video auto-play in the image_picker web example, not do any significant changes to the API of the video_player widget.

Copy link
Member Author

@ditman ditman Jul 1, 2020

Choose a reason for hiding this comment

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

I've created this issue so we can discuss this API change:

If we decide to add a "muted" attribute to the public API, this hack can be removed!

@ditman ditman requested a review from cyanglaz June 9, 2020 19:33
@ditman
Copy link
Member Author

ditman commented Jun 29, 2020

I'm not sure if it helps real-world apps, but Dart's Uri implementation is a spec-compliant implementation that's implemented in userspace. Last time I checked it was 18KB big. If this is for validation only, could it be wrapped in an assert?

@yjbanov I'll try what happens with malformed URLs, since this may be user-generated content.

@ditman
Copy link
Member Author

ditman commented Jul 1, 2020

Tested malformed URLs, and the plugin seems to be able to spit out an error that is understandable:

Error: PlatformException(MEDIA_ERR_SRC_NOT_SUPPORTED, MEDIA_ELEMENT_ERROR: Format error, The video
has been found to be unsuitable (missing or in a format not supported by your browser).)

@ditman ditman merged commit d3ccc34 into flutter:master Jul 1, 2020
@ditman ditman deleted the image-picker-example-video-fixes branch July 1, 2020 22:53
agent3bood pushed a commit to agent3bood/flutter-plugins that referenced this pull request Jul 10, 2020
This change adds small bugfixes to the following packages:

* video_player_web:
  * Prevent parsing Blob URLs so Safari can play from a PickedFile.
  * Allow users to 'mute' videos by setting their volume to 0.0 (this enables auto-play in most modern browsers)
* video_player:
  * Fix an issue where aspect ratio calculations failed when some of the video sizes were zero (happened in web for incorrect videos)
* image_picker (example app):
  * Start videos in web muted so they can auto-play
  * Dispose video controllers when they're really not needed. This fixes a fatal crash in Safari (not so fatal in other browsers).
jorgefspereira pushed a commit to jorgefspereira/plugins_flutter that referenced this pull request Oct 10, 2020
This change adds small bugfixes to the following packages:

* video_player_web:
  * Prevent parsing Blob URLs so Safari can play from a PickedFile.
  * Allow users to 'mute' videos by setting their volume to 0.0 (this enables auto-play in most modern browsers)
* video_player:
  * Fix an issue where aspect ratio calculations failed when some of the video sizes were zero (happened in web for incorrect videos)
* image_picker (example app):
  * Start videos in web muted so they can auto-play
  * Dispose video controllers when they're really not needed. This fixes a fatal crash in Safari (not so fatal in other browsers).
FlutterSu pushed a commit to FlutterSu/flutter-plugins that referenced this pull request Nov 20, 2020
This change adds small bugfixes to the following packages:

* video_player_web:
  * Prevent parsing Blob URLs so Safari can play from a PickedFile.
  * Allow users to 'mute' videos by setting their volume to 0.0 (this enables auto-play in most modern browsers)
* video_player:
  * Fix an issue where aspect ratio calculations failed when some of the video sizes were zero (happened in web for incorrect videos)
* image_picker (example app):
  * Start videos in web muted so they can auto-play
  * Dispose video controllers when they're really not needed. This fixes a fatal crash in Safari (not so fatal in other browsers).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants