I'm using B4i 3.50 with a VideoView (iMedia library) and attempting to have fullscreen mode automatically enabled or disabled based on whether the device is in portrait or landscape mode. It's almost working, but the dimensions reported while the video is in fullscreen mode are incorrect, even though the Resize event is firing at the expected times.
Here is the code I have to control fullscreen mode:
Here is the relevant output log data at first boot:
Now I rotate to landscape mode (iPhone 6 with iOS 10.2):
That is also correct, and the video switches to fullscreen mode as intended. Now I switch back to portrait, but look at the numbers:
The values still indicate landscape orientation, although height has changed by a value of 12. I can only imagine this is because the actual page is obstructed by the player, but the Resize event is still firing even though the page isn't visible.
If I tap the "exit fullscreen" icon manually in the player, then PageHome reappears and the correct width and height are given:
...but this defeats the purpose, since it requires user intervention other than simply rotating the device.
Hopefully there is some solution:
Here is the code I have to control fullscreen mode:
B4X:
Private Sub PageHome_Resize(Width As Int, Height As Int)
Log("PageHome_Resize(), Width=" & Width & ", Height=" & Height)
Dim vvo As NativeObject = vv
Dim player As NativeObject = vvo.GetField("player")
If Width > Height Then
Log("Enabling fullscreen")
player.RunMethod("setFullscreen:animated:", Array(True, False))
Else
Log("Disabling fullscreen")
player.RunMethod("setFullscreen:animated:", Array(False, False))
End If
End Sub
Here is the relevant output log data at first boot:
B4X:
Application_Start
Application_Active
PageHome_Appear()
PageHome_Resize(), Width=375, Height=603
Disabling fullscreen
Video ready
Now I rotate to landscape mode (iPhone 6 with iOS 10.2):
B4X:
PageHome_Resize(), Width=667, Height=343
Enabling fullscreen
That is also correct, and the video switches to fullscreen mode as intended. Now I switch back to portrait, but look at the numbers:
B4X:
PageHome_Resize(), Width=667, Height=331
Enabling fullscreen
The values still indicate landscape orientation, although height has changed by a value of 12. I can only imagine this is because the actual page is obstructed by the player, but the Resize event is still firing even though the page isn't visible.
If I tap the "exit fullscreen" icon manually in the player, then PageHome reappears and the correct width and height are given:
B4X:
PageHome_Appear()
PageHome_Resize(), Width=375, Height=603
Video width=375, height=210.7728
Disabling fullscreen
...but this defeats the purpose, since it requires user intervention other than simply rotating the device.
Hopefully there is some solution:
- Fix the Resize event to detect/show the right values
- Obtain orientation data from the media player somehow
- Obtain orientation data from the app or device rather than page dimensions
Last edited: