I am using a videoview filling the entire activity to play video, but when the video orientation (portrait or landscape) do not match the screen orientation, it plays on one side, and not centered.
There is an obvious solution: to set the videoview position and dimensions according to the video orientation and centered in the screen, but in order to do this, i would need to know which is the video orientation. MediaBrowser is of no help, because the Resolution property is always 1920x1080 for whichever orientation (it would have helped if it said 1080x1920 when in portrait mode, but it's not the case).
Solved, from another thread. The code (hopefully it would be self-explanatory) is:
B4X:
Dim rfl As Reflector
Dim obj As Object
obj = rfl.CreateObject("android.media.MediaMetadataRetriever")
rfl.Target = obj
rfl.RunMethod2("setDataSource", vidfile, "java.lang.String")
b = rfl.RunMethod3("getFrameAtTime", 0, "java.lang.long", 3, "java.lang.int")
If Not(b.IsInitialized) Then
ok = False
b.Initialize(File.DirAssets, "notavailable.png")
Else
HeightVideo = b.Height
WidthVideo = b.Width
End If
Where b is a bitmap and vidfile is a string containing the path to the video file. It does not work for streaming videos.