 Thread Author
# 1

07-12-2011, 01:45 AM
|
| CrackBerry Newbie | | Join Date: Jul 2011 Posts: 4 Likes Received: 0
Thanked 0 Times in 0 Posts
| |
problem to play video
class VideoView extends MainScreen
{
private Player _player;
private Field _videoField;
private VideoControl _vc;
// Constructor
public VideoView(final BrdcstMessage msg)
{
super(net.rim.device.api.ui.Manager.NO_VERTICAL_SC ROLL);
System.out.println("*****initVideo over*");
initVideo(msg._MsgUrl); //msg._MsgUrl = rtsp://website addess/some.3gp;
if(_videoField != null)
{
System.out.println("*****_videoField*"+_videoField );
displayVideo();
System.out.println("*****displayVideo over*");
}
}
private void setVideoSize(int width, int height)
{
try
{
if (_vc != null)
{
System.out.println("set video size");
_vc.setDisplaySize(width, height);
System.out.println("set video size---------");
}
}
catch(MediaException pe)
{
System.out.println(pe.toString());
}
}
/**
* Creates and initializes a video player
* @param url The URL of the video file to play
*/
private void initVideo(String url)
{
try
{
_player = javax.microedition.media.Manager.createPlayer(url) ;
_player.realize();
System.out.println("*****_player *"+_player);
_vc = (VideoControl) _player.getControl("VideoControl");
System.out.println("*****_vc *"+_vc);
if (_vc != null)
{
_videoField = (Field) _vc.initDisplayMode (VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
System.out.println("*****_videoField *"+_videoField);
_vc.setVisible(true);
}
}
catch(MediaException pe)
{
System.out.println("--------initVideo-----MediaException="+pe.getMessage());
}
catch (IOException ioe)
{
System.out.println("--------initVideo-----MediaException="+ioe.getMessage());
}
}
private void displayVideo()
{
// setTitle("Send Media Demo");
add(_videoField);
System.out.println("*****displayVideo-----------_videoField added*");
try
{
// Start media player
_player.start();
System.out.println("*****displayVideo-------------_player started*");
}
catch(MediaException pe)
{
System.out.println("--------displayVideo-----MediaException="+pe.getMessage());
}
}
protected void sublayout(int width, int height)
{
System.out.println("--------sublayout");
setVideoSize(Display.getWidth(), Display.getHeight());
super.sublayout(width, height);
}
public boolean onClose()
{
System.out.println("--------onClose");
_player.close();
System.out.println("onClose");
return super.onClose();
}
}
this is my code. i create media player to play the video file from server... when i try to run that i got some error.. the following error is
Thread [net_rim_services_impl(5)id=441311232] (Suspended (exception UnsupportedOperationException))
MediaPlayer.mediaLoaded(int) line: 622
MediaNatives$MediaNativesEventDispatcher.dispatch( Message, Object) line: 386
EventDispatchManager.dispatch(int, Message, Object[]) line: 59
Proxy(Application).processNextMessage(Message) line: 1704
Proxy(Application).enterEventDispatcher() line: 991
ServiceStartup.tier0() line: 90
ServiceStartup.main(String[]) line:
can u please tell me what is the problem in that code.. say some solution for that pls..
|