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

Java Development

Reply
New Developer
vprise
Posts: 16
Registered: ‎01-05-2009
My Device: Not Specified

Video Control In A Component That Draws Its Own UI (lightweight Component)

I'm one of the developers of the LWUIT framework. We have a great native RIM API port of LWUIT which runs really well and in quite a few production applications e.g.: http://lwuit.blogspot.com/2010/04/musix-on-blackberry-device.html

 

It supports touch pretty well including support for the Storms click screen functionality, tensile/kinetic drag etc.

 

We have video related issues in our issue tracker and its somewhat stumped me on how these issues can be fixed (both seem to be the same issue):

https://lwuit.dev.java.net/issues/show_bug.cgi?id=278

https://lwuit.dev.java.net/issues/show_bug.cgi?id=230

 

This link:

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/8 00332/1089414/How_To_-_Take_a_snapshot_using_the_built- in_camera_of_a_BlackBerry_smartphone.html?nodeid=1443849&vernum=0

 

Essentially claims that "USE_DIRECT_VIDEO" Isn't supported for Field items in the RIM API's... We use this constant and it does seem to work even in a field. I can't think of a possible way to change it since we handle all of our own drawing and this might collide with another component added on top.

Did we get the architecture "completely wrong" for RIM?

 

You can see the full source code for LWUIT here:

https://lwuit.dev.java.net/source/browse/lwuit/

 

You can see how we implemented the native RIM port here, the main method of concern is getVideoControl() although we might need a major architectural change as a result of changing this:

https://lwuit.dev.java.net/source/browse/lwuit/trunk/BlackBerry/BlackberryPort/src/com/sun/lwuit/imp...

 

Tips on how to embed a video into a double buffered field in a way that is portable between RIM devices/OS's would be appreciated.

 

Thanks.

Developer
rcmaniac25
Posts: 1,805
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.3253, Z10 (STL100-3)-10.3.1.997 Dev OS, Z30 (STA100-5)-10.3.1.997 Dev OS, Passport (SQW100-1)-10.3.0.1418, PlayBook (16GB)-2.1.0.1917

Re: Video Control In A Component That Draws Its Own UI (lightweight Component)

[ Edited ]

Judging by the error that https://lwuit.dev.java.net/issues/show_bug.cgi?id= 230 said they got, canvas.getDelegate() is either returning null or something that is not a LCDUI Canvas object.

 

I looked around and couldn't find the getDelegate() function so couldn't go any further.

 

Edit: https://lwuit.dev.java.net/issues/show_bug.cgi?id= 278 says that getDelegate() returns "net.rim.device.api.ui.container.TitleStatusManager" which (obviously) is not a LCDUI Canvas. As stated before I can't find getDelegate() so I don't know what it actually does.

 

Edit 2: Just realized that getDelegate() is a MainScreen function. In the simplest sense, getDelegate() returns type net.rim.device.api.ui.Manager, this is neither a Canvas nor a subclass of it. There's your problem.

 

Solution? You can try to use a Field (by using USE_GUI_PRIMITIVE) but that might not be compatible in the context of LWUIT, you can also try to wrap the Manager in a Canvas and simply pass the actions in Canvas to the Manager.

 

I'm really not sure but your problem is the getDelegate() function since it returns an incompatible type.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
New Developer
vprise
Posts: 16
Registered: ‎01-05-2009
My Device: Not Specified

Re: Video Control In A Component That Draws Its Own UI (lightweight Component)

Thanks for the reply.

I failed to mention that we tried both the canvas variable (which is a MainScreen) and its delegate.

 

We can't use an LCDUI Canvas since this is a native RIM application and these just don't offer the same integration on a blackberry device.

 

The problem is that I can't easily work with a Field object since we paint the entire screen using a double buffer. Regardless this will require some complex manipulation and management of that field that would need some major changes to LWUIT and might not even be possible.

 

Problem is that video works for me even on devices without that so I'm not sure if we should go to all that trouble which might not even work.

Developer
rcmaniac25
Posts: 1,805
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.3253, Z10 (STL100-3)-10.3.1.997 Dev OS, Z30 (STA100-5)-10.3.1.997 Dev OS, Passport (SQW100-1)-10.3.0.1418, PlayBook (16GB)-2.1.0.1917

Re: Video Control In A Component That Draws Its Own UI (lightweight Component)

That function actually works for you?

 

In that case the people who have the issue might be replacing the default Manager for the MainScreen and that might be incompatible.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
New Developer
vprise
Posts: 16
Registered: ‎01-05-2009
My Device: Not Specified

Re: Video Control In A Component That Draws Its Own UI (lightweight Component)

It works for me personally for video playback on the devices I tested.

Naturally it might not work on some devices and users have complained in two instances (listed above).

 

What I'm looking for is this:

Should I try to rewrite the code using the version of the method that returns a Field?

 

Will this work for me if I'm constantly drawing an image over the MainScreen (double buffering)?

Developer
rcmaniac25
Posts: 1,805
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.3253, Z10 (STL100-3)-10.3.1.997 Dev OS, Z30 (STA100-5)-10.3.1.997 Dev OS, Passport (SQW100-1)-10.3.0.1418, PlayBook (16GB)-2.1.0.1917

Re: Video Control In A Component That Draws Its Own UI (lightweight Component)

[ Edited ]

If you don't set the delegate and it works for you then see what those who logged the bugs are doing, if they are not changing the delgate then I have no clue. If they are then that's your problem, you could add a check to see if the degelage is a valid type:

public Object getVideoControl(Object player) {
    Manager man = canvas.getDelegate();
    //Make sure that the delegate is a valid type.
    if(!(man instanceof javax.microedition.lcdui.Canvas))
    {
        System.err.println("Non-compatable Canvas, returning null");
        return null;
    }
    VideoControl vidc = (VideoControl)((Player)player).getControl("VideoControl");
    vidc.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, man);
    return vidc;
}

 

Double-buffering shouldn't be a problem.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.