Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
chiguire
Posts: 23
Registered: ‎09-19-2012
My Device: BlackBerry PlayBook
Accepted Solution

Porting to BB10: Video rotation and display

I'm doing the porting of a game from the PlayBook to the Z10. I had to show a video at the beginning of the game, and I had some problems in the past with the PlayBook, but they were solved.

 

Now that I'm porting the same game to the BB10 platform, I'm finding myself with another problem related to the video. I have exhausted all my options, and I'm now asking for your help.

 

The problem I'm having is related to the default orientation of the devices. While the PlayBook defaults to a landscape orientation, the Z10 defaults to portrait.

 

So the easy solution is to simply set the orientation in the bar-descriptor.xml file to landscape, and set autoOrients to false, right? Well, this solves almost all the problem of porting the game: the rest of the game works really well, I just had to do something with the accelerometer.

 

However, the initial video appears distorted. Here's an screenshot of the Z10 rotated:

 

IMG_00000002.png

 

Here's my guess: when you test the game with the default/portrait orientation, the video appears distorted as well, but appears in the whole screen, adapting to the portrait dimensions. But when you set the ladscape orientation, it still adapts to the portrait dimensions, but now rotated.

 

Getting the screen properties through the screen_get_window_property_iv() function call while playing the video returns this:

 

SCREEN_PROPERTY_BUFFER_SIZE: {1280, 768}

SCREEN_PROPERTY_SIZE: {1280, 768}

SCREEN_PROPERTY_ROTATION: 90

 

There is apparently no way to alter the dimensions of the playing video, nor through the mmrenderer library or the screen library.

 

What kind of call should I use to alter the dimensions of the video so it appears correctly renderered?

 

Thanks.

Please use plain text.
New Contributor
Metl
Posts: 6
Registered: ‎03-15-2013
My Device: Z10

Re: Porting to BB10: Video rotation and display

Hey there,

 

This sample:

https://github.com/blackberry/NDK-Samples/tree/master/VideoWindow

 

Has some code in it that'll resize the rect accordingly depending on window size. Might be able to help you out in your quest.

Please use plain text.
Contributor
chiguire
Posts: 23
Registered: ‎09-19-2012
My Device: BlackBerry PlayBook

Re: Porting to BB10: Video rotation and display

The samples are already included in the NDK. That same sample behaved incorrectly, but I'm going to download that however, to see if they changed something. Thanks.

Please use plain text.
Contributor
chiguire
Posts: 23
Registered: ‎09-19-2012
My Device: BlackBerry PlayBook

Re: Porting to BB10: Video rotation and display

The updated VideoWindow sample in Github has the correct function (calculate_rect()) that displays the video correctly in the BB10. Thank you very much.

Please use plain text.
New Contributor
Metl
Posts: 6
Registered: ‎03-15-2013
My Device: Z10

Re: Porting to BB10: Video rotation and display

No problem. I had just gotten finished with dealing with the same issue. :-)

Please use plain text.
New Contributor
Metl
Posts: 6
Registered: ‎03-15-2013
My Device: Z10

Re: Porting to BB10: Video rotation and display

Have you had any luck getting the video window to rotate properly while the video is playing? I've been able to rotate the screen and then play the video but not play the video and then rotate the screen.

Please use plain text.
Contributor
chiguire
Posts: 23
Registered: ‎09-19-2012
My Device: BlackBerry PlayBook

Re: Porting to BB10: Video rotation and display

My apps are games and usually have only one orientation. I have still not found myself in the situation of having to rotate the screen while playing the video. Didn't it work out updating the strm dictionary when detecting the rotation?

Please use plain text.
New Contributor
Metl
Posts: 6
Registered: ‎03-15-2013
My Device: Z10

Re: Porting to BB10: Video rotation and display

With some help, I've got the solution to the problem:

 

When an orientation event occurs, the following things need to happen (in addition to resizing the gles and screen buffers accordingly)

 

1. clear the screen buffers using a screen_fill call

2. re-post the newly resized window using screen_post_window

3. If you're doing some aspect ratio compensation, the x and y offsets will need to be recalculated

Please use plain text.