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

[webview_flutter] Consistent allowsInlineMediaPlayback on iOS #2309

Closed

Conversation

alexmarkley
Copy link

@alexmarkley alexmarkley commented Nov 26, 2019

Description

By default, iPhone does not allow "inline" video in WKWebView, even if the content explicitly calls for it using the "playsinline" attribute. Instead, iPhone overrides the web view and produces a full screen video controller.

In contrast, iPad and Android provide support for "inline" media by default.

See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video#attr-playsinline
See Also: https://developer.apple.com/documentation/webkit/wkwebviewconfiguration/1614793-allowsinlinemediaplayback

Related Issues

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.
  • !1 My PR includes unit or integration tests for all changed/updated/fixed behaviors (See [Contributor Guide]).
  • All existing and new tests are passing.
  • !2 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.

Notes:

  • !1 The updated behavior is inside the platform code, not sure how to test it.
  • !2 This PR introduces no developer-facing changes.

Breaking Change

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

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

@alexmarkley
Copy link
Author

I went ahead and created a (very simple) patch to address this very annoying issue.

I did not see it at first but now I see there is a (better and more robust?) PR already submitted to do the job: #2227

I would be happy to abandon my PR in favor of @sarbagyastha's version if his has a chance of getting merged.

@ened
Copy link
Contributor

ened commented Dec 3, 2019

hi @alexmarkley - cool & thank you for the PR.
Do you think we should make this flag configurable for the user (and by default keep it off, so that users who upgrade the plugin experience the same behavior as before).
In order to merge your PR, we will also need a test, version bump and a entry to the change log.
Would you be able to work on this?
Thank you!

@alexmarkley
Copy link
Author

@ened Currently this flag's behavior is different across different Apple devices, which means that the current end user experience is inconsistent between iOS and iPad.

The current behavior on iPhone is to ignore the playsinline attribute for <video> tags, so this pull request merely allows the content to specify whether the media should be played inline or not.

As such I would be absolutely shocked if it introduced any unexpected or unwanted changes to any users of this plugin.

However, as I mentioned earlier, if we want a more robust implementation of this functionality which exposes the platform-specific flags to the Flutter code, perhaps we should encourage @sarbagyastha and get his PR accepted: #2227

On another note, with regards to a test, I don't know how that would work. How can we implement a test for this behavior?

Either way I will go ahead and rebase with a new changelog and version bump.

@alexmarkley alexmarkley force-pushed the inline-media-behavior branch from eec2244 to dde72a9 Compare December 4, 2019 01:08
@alexmarkley
Copy link
Author

@ened I went ahead and cleaned up the pull request to track the latest upstream changes.

Also, to clarify, I am having trouble seeing the value of exposing this flag at the Flutter/Widget level, since you would then have to turn it on twice -- once in your HTML5 <video> tag and once again in your Widget.

That said, I am not dogmatic about it, I'm happy to see the problem solved no matter how it gets solved. 😄

@rayliverified
Copy link

rayliverified commented Dec 12, 2019

Also, to clarify, I am having trouble seeing the value of exposing this flag at the Flutter/Widget level, since you would then have to turn it on twice -- once in your HTML5 <video> tag and once again in your Widget.

A Flutter level setting would be useful because most of the videos on the web are streamed from video sharing platforms (Youtube, Vimeo, etc) with embed video settings.

Those videos are embedded with an iframe and does not support tag configurations because the code is in the iframe and controlled by the platform itself.

Thanks for making the PR!

@rayliverified
Copy link

Any update on this PR?

@alexmarkley
Copy link
Author

@searchy2 Vimeo does allow this setting to be modified via their embed api (see the playsinline parameter here): https://developer.vimeo.com/player/sdk/embed

Either way, if we want a more robust (read: complex) solution, please see #2227

Until @sarbagyastha's solution gets merged, I'll just keep updating this PR to track master.

@alexmarkley alexmarkley force-pushed the inline-media-behavior branch from dde72a9 to d34c05f Compare December 19, 2019 19:13
@vlowe85
Copy link

vlowe85 commented Jan 13, 2020

Been waiting for this feature for a while, currently this feature is supported in flutter_inappwebview but would rather not import both.

@alexmarkley alexmarkley force-pushed the inline-media-behavior branch from d34c05f to cd30231 Compare January 27, 2020 13:26
@alexmarkley
Copy link
Author

I just rebased my patch against origin again. Solving this problem is a requirement for my use case, and I'm currently using this patch (until some solution gets upstreamed).

If anybody with merge rights would be willing to provide more concrete guidance on what steps would be necessary and appropriate for getting this merged, I would be happy to do a little more work to get it done.

Thanks!

@Phasor1
Copy link

Phasor1 commented Apr 1, 2020

Thank you @alexmarkley, i'm waiting too for an update on this solution

@alexmarkley alexmarkley force-pushed the inline-media-behavior branch from 263bec6 to 9609f67 Compare April 6, 2020 14:44
@alexmarkley
Copy link
Author

stevemoreau added a commit to mobizel/flutter-plugins that referenced this pull request May 18, 2020
A PR exists to propagate a configuration parameter from the GUI, but it is not merged yet flutter#2309
@CyrilHu
Copy link

CyrilHu commented May 29, 2020

any updates on this?

@lgArlequin
Copy link

Any news?

@LinetCheese
Copy link

Are there any updates on this?

@alexmarkley alexmarkley force-pushed the inline-media-behavior branch from 184b233 to 836d9b9 Compare July 30, 2020 12:49
@alexmarkley
Copy link
Author

I rebased my patch against master again. Still looking for guidance on how to proceed with this.

TBH I disagree with @searchy2 and @ened. I do not believe this is a new feature, I am of the opinion that this is a bug for all affected users, and the risk of backwards-incompatible behavior is vanishingly small.

@alexmarkley alexmarkley force-pushed the inline-media-behavior branch from 836d9b9 to 3148af8 Compare August 27, 2020 02:44
@alexmarkley
Copy link
Author

Rebased again.

@Pebsie
Copy link

Pebsie commented Sep 29, 2020

Those seem like some awfully easy conflicts to fix ^^

@alexmarkley alexmarkley force-pushed the inline-media-behavior branch from 3148af8 to cec2cf8 Compare October 1, 2020 01:01
@alexmarkley
Copy link
Author

Rebased again.

@Steven-Chen87
Copy link

When will this fix release?

@stuartmorgan-g stuartmorgan-g added the p: webview_flutter Edits files for a webview_flutter plugin label Jan 29, 2021
@stuartmorgan-g
Copy link
Contributor

Thanks for the contribution!

I did not see it at first but now I see there is a (better and more robust?) PR already submitted to do the job: #2227

I would be happy to abandon my PR in favor of @sarbagyastha's version if his has a chance of getting merged.

Since it appears that was landed as #3334, I'm going to close this as obsolete. If that's not the case, please let me know.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes p: webview_flutter Edits files for a webview_flutter plugin platform-ios
Projects
None yet
Development

Successfully merging this pull request may close these issues.