Skip to main content

Strange MediaComponent behaviour

1 reply [Last post]
kawaiimomo
Offline
Joined: 2008-07-10

Hello all,

This is the way how I get the media Player:

<br />
if (mPlayer == null) {<br />
	try {<br />
		mPlayer = Manager.createPlayer("capture://video");<br />
		mPlayer.realize();<br />
		mPlayer.start();<br />
	} catch (Exception e) {<br />
		e.printStackTrace();<br />
	}<br />
}<br />

I'm using a BorderLayout with only the MediaComponent in the Center. I tried to control the size of the Component by padding, but has no effect (same for padding 0 or 100). So i'm controlling it with margins.

<br />
MediaComponent a = new MediaComponent(mPlayer);<br />
a.getStyle().setMargin(20,20,20,20);</p>
<p>form.addComponent(BorderLayout.CENTER, a);<br />

If I use 10 px margin, there's no problem but i need the video smaller, so I tried with 20 px. And this is the result... http://www.4shared.com/file/55268384/81ec2fba/nooverriden.html?
Weird...

Now, creating the MediaComponent overriding the calcPreferredSize() method works great. I mean, it doesn't really use that Dimension because of the BorderLayout, but the margins that were giving problems are working nicely now.
Any idea of why this happens? The original Dimensions before overriding were 160x120...

<br />
MediaComponent a = new MediaComponent(mPlayer) {<br />
	protected Dimension calcPreferredSize() {<br />
		return new Dimension(50,50);<br />
	}<br />
};<br />

And here's the result:
http://www.4shared.com/file/55268405/3b7d83a1/overriden.html?

Note that the MediaComponent is not 50x50 px as specified, but the strange behaviour disappears.

Regards.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
chen

Ok,
There are a few things that happened here:
1)The media Component uses MMAPI to draw the video, most of the mmapi
implementations will draw the video in a different layer on top of our
GameCanvas and won't respect the clipping area, this is why the video is
drawn on top of the menu.
2)The margins and padding staff I will have to check and let you know

Regards,
Chen

lwuit-users@mobileandembedded.org wrote:
> Hello all,
>
> This is the way how I get the media Player:
>
> [code]
> if (mPlayer == null) {
> try {
> mPlayer = Manager.createPlayer("capture://video");
> mPlayer.realize();
> mPlayer.start();
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
> [/code]
>
>
> I'm using a BorderLayout with only the MediaComponent in the Center. I tried to control the size of the Component by padding, but has no effect (same for padding 0 or 100). So i'm controlling it with margins.
>
> [code]
> MediaComponent a = new MediaComponent(mPlayer);
> a.getStyle().setMargin(20,20,20,20);
>
> form.addComponent(BorderLayout.CENTER, a);
> [/code]
>
> If I use 10 px margin, there's no problem but i need the video smaller, so I tried with 20 px. And this is the result... [url]http://www.4shared.com/file/55268384/81ec2fba/nooverriden.html?[/url]
> Weird...
>
> Now, creating the MediaComponent overriding the calcPreferredSize() method works great. I mean, it doesn't really use that Dimension because of the BorderLayout, but the margins that were giving problems are working nicely now.
> Any idea of why this happens? The original Dimensions before overriding were 160x120...
>
> [code]
> MediaComponent a = new MediaComponent(mPlayer) {
> protected Dimension calcPreferredSize() {
> return new Dimension(50,50);
> }
> };
> [/code]
>
> And here's the result:
> [url]http://www.4shared.com/file/55268405/3b7d83a1/overriden.html?[/url]
>
> Note that the MediaComponent is not 50x50 px as specified, but the strange behaviour disappears.
>
> Regards.
> [Message sent by forum member 'kawaiimomo' (kawaiimomo)]
>
> http://forums.java.net/jive/thread.jspa?messageID=286737
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net