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
Developer
dbigham
Posts: 469
Registered: ‎04-01-2009
My Device: Z10, PlayBook
My Carrier: NA

Porting Flix to BB10

Hi folks,

 

It's time for me to get my "Flix" app working on BB10. Hopefully RIM will be successful getting a Netflix-built app for BB10, but in case they don't I figure I should have Flix ready.

 

The app itself already "works" on BB10 without any modification, but what I'd like to do is integrate a web view control into the app so that I don't need a secondary Adobe AIR app to allow a user to select which movie they'd like to watch.

 

That will require a significant change to how the app uses the screen. Right now, I'm using C calls in Flix like:

 

screen_create_context(&screen_ctx, 0);
screen_create_window(&screen_win, screen_ctx);
screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage);

screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_RENDER_BUFFERS,

 

int viewport_size[2] = { 0, 0 };


(void **) &screen_buf);
screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE,
rect + 2);
viewport_size[0] = rect[2];
viewport_size[1] = rect[3];
screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SOURCE_SIZE,
viewport_size);

screen_post_window(screen_win, screen_buf, 1, rect, 0);

 

int load_image(screen_window_t screen_win, const char *path) {
img_decode_callouts_t callouts;
img_t img;
int rc;

memset(&img, 0, sizeof(img));
img.flags |= IMG_FORMAT;
img.format = IMG_FMT_PKLE_XRGB8888;

memset(&callouts, 0, sizeof(callouts));
callouts.setup_f = decode_setup;
callouts.abort_f = decode_abort;
callouts.data = (uintptr_t) screen_win;

rc = img_load_file(ilib, path, &callouts, &img);

return rc == IMG_ERR_OK ? 0 : -1;
}

 

etc. etc.

 

In turning this into a Cascades application, what I will want to do is to continue to do the above for writing to the screen, etc, but when they access the "Browse Movies" button, I'll need to flip into "Cascades" mode whereby it shows a QML file with a WebView.


Then, when they select a movie, I'll want to flip back to using C APIs to control the screen.

 

I figured I'd at least ask the community first what direction I should be following to accomplish something like this. Does this relate to ForeignWindow, or something else?

 

Thanks so much in advance.

 

Daniel

 

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Porting Flix to BB10

If you're trying to combine stuff like that above, with Cascades WebView, in the same app, then ForeignWindowControl is definitely the place to go. There's a sample using that... the one with the big simulated TV screen showing static.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
dbigham
Posts: 469
Registered: ‎04-01-2009
My Device: Z10, PlayBook
My Carrier: NA

Re: Porting Flix to BB10

Thanks!

 

I've got the foreign window example code working, which uses a pixmap, but when I try to adapt it to my code which makes use of:

 

static void update_screen() {
int viewport_size[2] = { 0, 0 };

screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_RENDER_BUFFERS,
(void **) &screen_buf);
screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE,
rect + 2);
viewport_size[0] = rect[2];
viewport_size[1] = rect[3];
screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SOURCE_SIZE,
viewport_size);

screen_post_window(screen_win, screen_buf, 1, rect, 0);
}

static int decode_setup(uintptr_t data, img_t *img, unsigned flags) {
screen_window_t screen_win = (screen_window_t) data;
screen_buffer_t screen_buf;

if (buffersCreated == 0) {
int size[2];
size[0] = img->w;
size[1] = img->h;
screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE,
size);
screen_create_window_buffers(screen_win, 1);
buffersCreated = 1;
}

screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_RENDER_BUFFERS,
(void **) &screen_buf);
screen_get_buffer_property_pv(screen_buf, SCREEN_PROPERTY_POINTER,
(void **) &img->access.direct.data);
screen_get_buffer_property_iv(screen_buf, SCREEN_PROPERTY_STRIDE,
(int *) &img->access.direct.stride);

img->flags |= IMG_DIRECT;
return IMG_ERR_OK;
}

img_lib_t ilib = NULL;

static void decode_abort(uintptr_t data, img_t *img) {
screen_window_t screen_win = (screen_window_t) data;
screen_destroy_window_buffers(screen_win);
fprintf(stderr, "decode_abort\n");
}

int load_image(screen_window_t screen_win, const char *path)
{
img_decode_callouts_t callouts;
img_t img;
int rc;

memset(&img, 0, sizeof(img));
img.flags |= IMG_FORMAT;
img.format = IMG_FMT_PKLE_XRGB8888;

memset(&callouts, 0, sizeof(callouts));
callouts.setup_f = decode_setup;
callouts.abort_f = decode_abort;
callouts.data = (uintptr_t) screen_win;

rc = img_load_file(ilib, path, &callouts, &img);

fprintf(stderr, "load_image\n");

return rc == IMG_ERR_OK ? 0 : -1;
}

 

... it just shows a black screen. Strange.

 

I'll keep hacking...

Please use plain text.