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

Support fullscreen video on Android #325

Merged

Conversation

dvicory
Copy link
Contributor

@dvicory dvicory commented Feb 7, 2019

Fixes #294.

Let me know if we want to add anything as part of this.

@smathson
Copy link
Contributor

smathson commented Feb 14, 2019

@dvicory This works great! Wish I had seen it earlier this week before I did almost identical work on my own fork. Your implementation is much cleaner though, so going to use yours and hope it gets merged soon. Nice work!

Edit: After some further testing I ran into an issue trying to fullscreen videos that were captured in portrait orientation. More details below.

@Titozzz
Copy link
Collaborator

Titozzz commented Feb 15, 2019

I'll wait for updates from @dvicory to merge, but many thanks for testing @smathson

@dvicory
Copy link
Contributor Author

dvicory commented Mar 14, 2019

@Titozzz and @smathson sorry for the very late followup, but I've addressed the original issue of forcing orientation. Currently, I've made the best fullscreen experience only for KitKat or greater. I hope that's acceptable as getting it working well pre-KitKat turned out to be quite a challenge. Fullscreen video will still work there, just with the navigation and status bars.

Right now it uses sticky immersive mode (for KitKat and above), doesn't force orientation, and works well if a user locks the screen or backgrounds the app. Let me know if I can address anything further.

@smathson
Copy link
Contributor

@dvicory Looks great to me. I won't have a chance to test this in our production app anytime soon but I'll try to run it through a test app tomorrow or early next week.

@Titozzz
Copy link
Collaborator

Titozzz commented Mar 22, 2019

@dvicory Any change you can get a look at the conflicts? I merged quite a lot of stuff recently

@dvicory
Copy link
Contributor Author

dvicory commented Mar 22, 2019

@Titozzz Rebased and resolved conflicts. Also I've tested on the following devices we have:

Nexus 7 with Android 4.3
Nexus 5 with Android 6.0.1
Samsung S7 with Android 7.0
Samsung S9 with Android 8.0
Pixel 2 with Android 9.0

Couldn't find our phone with KitKat unfortunately.

@Titozzz
Copy link
Collaborator

Titozzz commented Mar 23, 2019

Great, thanks

@Strate
Copy link

Strate commented Apr 1, 2019

did you checked how embedded youtube works in fullscreen? I've tried your PR, but there was an issues:

  1. Sometimes "fullscreen" button is not tapable on real device (Xiaomi Redmi 6A)
  2. When button is tapable, video missing on fullscreen, only audio available.

@dvicory
Copy link
Contributor Author

dvicory commented Apr 1, 2019

@Strate I experienced the same problem on my Nexus 6P with a custom ROM (Pixel Experience), but attributed it to the custom ROM... Other Nexus, Samsung, and Pixel phones have no problems. I would appreciate any help in investigating what's going wrong here. I don't know that this should be a blocker to merging?

@Titozzz
Copy link
Collaborator

Titozzz commented Apr 2, 2019

@Strate @dvicory please keep me updated if this is a blocker or not :)

@Strate
Copy link

Strate commented Apr 2, 2019

@Titozzz actually, this happens with other webview components (I've tried https://github.com/teamairship/react-native-android-fullscreen-webview-video). Looks like this is a youtube-related problem, because Vimeo works great.

@Titozzz
Copy link
Collaborator

Titozzz commented Apr 2, 2019

So you are saying we can merge this as is?

@Strate
Copy link

Strate commented Apr 3, 2019

@Titozzz I can't say this, because actually I am not an android developer, I just tried to find out youtube fullscreen problem, found this PR and tested it )

@adrianchinghc
Copy link

Manually applied the changes to test this out. This is for youtube and vimeo embed in a website. (Huawei Nova 3)

For youtube embed, the fullscreen icon is not greyed out anymore. But when I tap on the icon, nothing happens. Seeing this mSecurityInputMethodService is null in logcat.

As for vimeo embed, when I tap on the fullscreen icon, the screen becomes white colour. But the video is actually already full screen and playing below the white screen.

@miltoneiji
Copy link

Is there anything that I can do to help this PR to get merged?

I was thinking of creating a repo with this branch and try to reproduce the bug. Would it help?

ambrosiora
ambrosiora previously approved these changes May 7, 2019
Copy link

@ambrosiora ambrosiora left a comment

Choose a reason for hiding this comment

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

I'm trying to implement this feature on my app. So I get this modified file and manually applied the changes to test. Here's the tests result bellow:

Galaxy S8 - Android 9.0. - Fullscreen button working fine.

Lenovo Z2 Plus - Android 7.1.2. - Fullscreen button working fine.

Tested on 3 Moto X Play with Android 7.1.1. - Fullscreen button working fine.

Samsung Galaxy J7 - Android 6.0.1 - Fullscreen button working fine.

One of these Moto X Play is mine and the only strange issue that hapend on my cellphone is: The Fullscreen button appears enabled but nothing happens on tap at first try, so I uninstalled the app and run react-native run-android --deviceId=<MY_DEVICE_ID_HERE> again and it works fine.

Unfortunately, I'm not able to analyze and suggest any changes on the Java Code.
I hope I helped, and I'm waiting this solution gets fully merged soon.
Thanks :D

@karvulf
Copy link

karvulf commented May 8, 2019

I tested it on my Galaxy Tab S2 with Android 7.0 and in fullscreen, my screen gets black, if my rotation is portrait (sound works and video is clickable), in landscape mode, it works.
And on my Galaxy s7 with Android 8.0, if I change multiple times the rotation in fullscreen, sometimes the screen gets black (sound works and video is clickable)

@Titozzz
Copy link
Collaborator

Titozzz commented May 10, 2019

If anyone can find the reasons for the last few bugs it would be great as it already looks like it's working on many devices

@sibelius
Copy link

can we ship this as experimental? would this break other features?

@Titozzz
Copy link
Collaborator

Titozzz commented May 13, 2019

I could. I can always revert if something gets broken but I guess it should only affect people using full screen and since it's broken right now..

@karvulf
Copy link

karvulf commented May 15, 2019

That would be great and easier for me to test it! @dvicory

@dvicory
Copy link
Contributor Author

dvicory commented May 15, 2019

@karvulf Okay, I made a branch with the TypeScript built.

You should be able to add it like so: yarn add "github:appfolio/react-native-webview#built-android-fullscreen-video". Please let me know how it works out for you. For other readers out there, please don't depend on this branch long-term, the goal is to get this merged. 😄

@karvulf
Copy link

karvulf commented May 15, 2019

Thank you very much! It works @dvicory

@dvicory
Copy link
Contributor Author

dvicory commented May 16, 2019

@sibelius @smathson Anything more I can do to help push this through?

@Titozzz
Copy link
Collaborator

Titozzz commented May 16, 2019

Nope, you already rock 😍

@Titozzz Titozzz merged commit d72c2ae into react-native-webview:master May 16, 2019
react-native-community-bot pushed a commit that referenced this pull request May 16, 2019
# [5.9.0](v5.8.2...v5.9.0) (2019-05-16)

### Bug Fixes

* **Android:** geolocation access ([#562](#562)) ([409b9ae](409b9ae))

### Features

* **fullscreen videos:** Support fullscreen video on Android ([#325](#325)) ([d72c2ae](d72c2ae))
* **onScroll:** Add `onScroll` callback for iOS & Android ([#516](#516)) ([e4c8dab](e4c8dab))
@react-native-community-bot
Copy link
Collaborator

🎉 This PR is included in version 5.9.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Mookiies
Copy link
Contributor

@allcontributors[bot] please add @dvicory for code doc

@allcontributors
Copy link
Contributor

@MalcolmScruggs

I've put up a pull request to add @dvicory! 🎉

@ambrosiora
Copy link

Nice job fellows!
Like I said above, if any user reports some unexpected behaviour , I will stat you guys.
Thanks!

@ouabing
Copy link

ouabing commented May 20, 2019

Any ideas about getting notified when enter/exit fullscreen? I'm seeking for a way on Android to unlock the orientations when the webview enters fullscreen mode to enable auto-rotate feature, and lock it again when exits.

WKWebView handles this case well on iOS side, so it's a bit inconsistent on this. Temporarily my workaround is changing the Java code to emit exit and enter events. I don't know if it's a good idea to add another callback for Android : /.

@dvicory
Copy link
Contributor Author

dvicory commented May 20, 2019

@ouabing perhaps continue this discussion in #586.

Palid added a commit to Palid/react-native-webview that referenced this pull request May 22, 2019
Fix missing `allowsFullscreenVideo` prop after react-native-webview#325 got merged.
Titozzz pushed a commit that referenced this pull request Jun 13, 2019
Fix missing `allowsFullscreenVideo` prop after #325 got merged.
Titozzz pushed a commit that referenced this pull request Jun 13, 2019
Fix missing `allowsFullscreenVideo` prop after #325 got merged.
phuongwd pushed a commit to phuongwd/react-native-webview that referenced this pull request Apr 29, 2020
…ative-webview#325)

* Extract WebChromeClient from an anonymous class

* Support fullscreen videos on Android

Forces landscape mode while playing.

* Use sticky immersive mode for fullscreen videos

No longer forces landscape mode as that is a problem for portrait videos - allow
the user to rotate as necessary.

Only supports KitKat or greater, and falls back to leaving the status and navigation
bars visible for lower than KitKat. This is the easiest way to prevent issues with
resizing the video during playback.

Also implement a lifecyle event listener which means if a user backgrounds the app
or locks the screen with the video fullscreen, the UI visibility is re-applied.

* Add allowsFullscreenVideo prop to control whether videos can be fullscreen on Android

Luckily, we're able to change the WebChromeClient on demand in response to prop changes
without seeming to do any harm. If you switch to disallow fullscreen, it will attempt
to close the currently fullscreened video (if there is one) so users aren't stuck.

I did notice a bug that if you go from fullscreen allowed, to fullscreen disallowed,
the fullscreen button will remain on the video. Tapping the button will have no effect.
phuongwd pushed a commit to phuongwd/react-native-webview that referenced this pull request Apr 29, 2020
# [5.9.0](react-native-webview/react-native-webview@v5.8.2...v5.9.0) (2019-05-16)

### Bug Fixes

* **Android:** geolocation access ([react-native-webview#562](react-native-webview#562)) ([409b9ae](react-native-webview@409b9ae))

### Features

* **fullscreen videos:** Support fullscreen video on Android ([react-native-webview#325](react-native-webview#325)) ([d72c2ae](react-native-webview@d72c2ae))
* **onScroll:** Add `onScroll` callback for iOS & Android ([react-native-webview#516](react-native-webview#516)) ([e4c8dab](react-native-webview@e4c8dab))
phuongwd pushed a commit to phuongwd/react-native-webview that referenced this pull request Apr 29, 2020
noproblem23 added a commit to noproblem23/react-native-webview that referenced this pull request Apr 18, 2023
# [5.9.0](react-native-webview/react-native-webview@v5.8.2...v5.9.0) (2019-05-16)

### Bug Fixes

* **Android:** geolocation access ([#562](react-native-webview/react-native-webview#562)) ([409b9ae](react-native-webview/react-native-webview@409b9ae))

### Features

* **fullscreen videos:** Support fullscreen video on Android ([#325](react-native-webview/react-native-webview#325)) ([d72c2ae](react-native-webview/react-native-webview@d72c2ae))
* **onScroll:** Add `onScroll` callback for iOS & Android ([#516](react-native-webview/react-native-webview#516)) ([e4c8dab](react-native-webview/react-native-webview@e4c8dab))
noproblem23 added a commit to noproblem23/react-native-webview that referenced this pull request Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Android needs full screen video support