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: 207
Registered: ‎09-10-2010
My Device: Not Specified
Accepted Solution

Help - BrowserField2, Media Player and Threads

 

Hello everyone

 

In my application, I have BrowserField2 added to MainScreen and Media player based on Streaming media - Start to finish. I am trying to open media player from Browser using extended javascript. My plan is that when user clicks on some links in web page, I call extended javascript function with some parameters like url of the video to stream. This function in turn pushes media player screen with the url passed. Media player works very well and streams video when used stand alone. But it doesn't  play video when coupled with BrowserField using extended javascript.

 

I suspect that the issue is synchronizing with Event thread or related to threading. I push screen containing media player using runnable. The screen is displayed. But when I click on play button (which starts some threads to fetch video and play it), nothing happens and my application freezes. I am not able to figure out exact problem. Will appreciate if someone can pin point the problem. 

 

Thank you.

 

Some relevant code listings as below:

 

 public void extendJavaScript() throws Exception
 {        
    ScriptableFunction playVideo = new ScriptableFunction()
   {            
      public Object invoke(Object thiz, Object[] args) throws Exception
      {
                openMediaPlayer(args[0].toString());
        	return Boolean.FALSE;
       }
    };
    _bf2.extendScriptEngine("bb.playVideo", playVideo);        
}

 

private void openMediaPlayer(final String url){
	UiApplication.getUiApplication().invokeAndWait(new Runnable() {
	    
	    public void run() {
		PlayerScreen _playerScreen = new PlayerScreen(url + ";deviceside=true");
		UiApplication.getUiApplication().pushScreen(_playerScreen);		
	    }
	});	
    }

 

 

 

 

 

 

Developer
Posts: 207
Registered: ‎09-10-2010
My Device: Not Specified

Re: Help - BrowserField2, Media Player and Threads

Never mind. Got it resolved. It turned out that the video that I was trying to access from web page was in incompatible format and hence throwing an error and freezing the app.