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
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: has anyone used Navigator_Invoke? Anyone at RIM tried it??

What does navigator_invoke return first of all? BPS_SUCCESS or BPS_FAILURE?

Contributor
Posts: 27
Registered: ‎09-03-2012
My Device: Blackberry Playbook
My Carrier: None

Re: has anyone used Navigator_Invoke? Anyone at RIM tried it??

hi BGmot

my understanding from the API is that I should pass in an uninitialised char**. The APi would initialise it and return an error string.

BPS_SUCCESS and BPS_FAILURE are integer values; where are these returned?

 

But if I pass an uninitialised char** into navigator_invoke, I get a crash. If I malloc it, nothing is set in the char**.

 

I'm clearly doing something very wrong, I just need some kind soul to tell me the 2 or 3 lines needed to get this API to work on a file in the shared folder Smiley Sad

 

Just to recap, from the documentation I thought this would work, it crashes:

char **err;
navigator_invoke("videos://shared/shared.mp4", err);
printf(*err);

 And the below code doesn't crash but fails to give any error in the err variable but on screen it starts the video player and a popup says "Media Error  Cannot open the file. Check the file permissions and try again".

char **err = (char **)malloc(sizeof(char *) * 2000);
navigator_invoke("videos://shared/shared.mp4", err);
printf(*err);

I have media_shared in my bar description xml file.

 

thanks

 

BlackBerry Development Advisor
Posts: 38
Registered: ‎10-26-2011
My Device: BlackBerry Bold 9900
My Carrier: Rogers

Re: has anyone used Navigator_Invoke? Anyone at RIM tried it??

The correct way to use navigator_invoke() is as follows:

 

char *err = NULL;
int rc = navigator_invoke("videos:///accounts/1000/shared/videos/cover.mp4", &err);

if (rc == BPS_SUCCESS) {
  /* it worked */
} else {
  /* see why it failed */
  fprintf(stderr, "The error: %s\n", err);
}

bps_free(err);

Some points:

 

Note the 3 slashes after "videos:".  This parallels the standard "file:" URL scheme.

 

The err string will not be touched by navigator_invoke() unless there's an error, i.e. unless it returns BPS_FAILURE.  Some of your code snippets did not initialize the err string so if it's garbage, it will remain garbage after the call to navigator_invoke().

 

The above code initializes err to NULL, so the bps_free() will always be ok (since freeing address 0 is not an error).

 

An alternative is to use navigator_open_file().  Replace the second line in the above code block with:

 

int rc = navigator_open_file("/accounts/1000/shared/videos/cover.mp4", &err);

 

Developer
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: has anyone used Navigator_Invoke? Anyone at RIM tried it??

int rc = navigator_invoke("videos:///accounts/1000/shared/videos/cover.mp4", &err);

does not work for me. It returns BPS_SUCCESS, it launches Video player but this Video player throws the error (a pop-up window): "Media error Cannot open the file. Please check the file permissions and try again"

 

BlackBerry Development Advisor
Posts: 38
Registered: ‎10-26-2011
My Device: BlackBerry Bold 9900
My Carrier: Rogers

Re: has anyone used Navigator_Invoke? Anyone at RIM tried it??


BGmot wrote:
int rc = navigator_invoke("videos:///accounts/1000/shared/videos/cover.mp4", &err);

does not work for me. It returns BPS_SUCCESS, it launches Video player but this Video player throws the error (a pop-up window): "Media error Cannot open the file. Please check the file permissions and try again"

 


Well at that point it's a problem with the Video Player.  Do you have a file named "cover.mp4" in your videos directory?

 

Highlighted
Contributor
Posts: 27
Registered: ‎09-03-2012
My Device: Blackberry Playbook
My Carrier: None

Re: has anyone used Navigator_Invoke? Anyone at RIM tried it??

many thanks for the responses guys.

 

BGmot is right, the navigator_invoke returns BPS_SUCCESS but gives the error he describes from the video player.

But the second method jhoffmann recommended, using navigator_open_file, works!!!

Many thanks to BGmot and jhoffmann, I finally got to where I want to be Smiley Happy