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
Developer
Posts: 402
Registered: ‎11-26-2010
My Device: Torch
Accepted Solution

StreamingBufferControl usage?

Can anyone explain how to use StreamingBufferControl?

From the docs it is supposed to flush the buffered content in the player which is not yet played - http://www.blackberry.com/developers/docs/4.7.0api/

 

I found an example :

 

StreamingBufferControl sbc = 
(StreamingBufferControl)_player.getControl("net.rim.device.api.media.control.Streaming
BufferControl");
if(sbc != null) {
sbc.flush();
}

 

The problem is that sbc is always null! When and how am I supposed to get this control and be able to flush the player's buffer properly?

 

----------------------------------------------------------------------
Press the button to give kudos if I helped you Smiley Happy
Developer
Posts: 402
Registered: ‎11-26-2010
My Device: Torch

Re: StreamingBufferControl usage?

[ Edited ]

Some more info:

I am testing on a BB Pearl 9100 device.

I tried it before and after each of the phases of the player - unrealized,realized, started and there is no such control.

I tried getting all the controls with player.getControls() and print their classes and here is what i got:

net.rim.device.internal.media.StreamingMediaPlayer

net.rim.device.internal.media.AdvancedVolumeControlImpl

net.rim.device.internal.media.StreamingMediaPlayer$GapelessPlaybackControlImpl

 

EDIT:

Solved - I wasn't using the correct way to get the control.

----------------------------------------------------------------------
Press the button to give kudos if I helped you Smiley Happy
Highlighted
New Contributor
Posts: 7
Registered: ‎02-24-2011
My Device: Bold 9700

Re: StreamingBufferControl usage?

Hello,

 

How were you able to get access to this control?  

I have tried this at all states and i dont get an illegalstateexception (meaning i try to get it when the player is in a good state) , it's just null always.

 

Thanx

 

Developer
Posts: 402
Registered: ‎11-26-2010
My Device: Torch

Re: StreamingBufferControl usage?

[ Edited ]

The trick is to iterate through the controls, check with instanceof and cast. Here is the code:

 

 

Control[] controls = player.getControls();
StreamingBufferControl sbc = null;
for (int i = 0; i < controls.length; i++) {
  if(controls[i] instanceof StreamingBufferControl){
    sbc = (StreamingBufferControl)controls[i];
    break;
  }
}

 

----------------------------------------------------------------------
Press the button to give kudos if I helped you Smiley Happy