专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > J2ME

J2ME 播放视频 只有声音解决方法

发布时间:2010-06-05 12:40:47 文章来源:www.iduyao.cn 采编人员:星星草
J2ME 播放视频 只有声音
小弟在做一个视频播放器,用S40第六版模拟器,用3GP格式的视频,但是屏幕上只有声音,没有任何画面显示。部分代码如下:

try {
FileConnection currDir;
currDir = (FileConnection) Connector.open(url);
System.out.println("00");
if (!currDir.exists()){
return false;
}
System.out.println("11");
InputStream is = null;
is = currDir.openInputStream();
System.out.println("22");
player = null;
// player = Manager.createPlayer(is, MusicType);
player = Manager.createPlayer(url);
System.out.println("33");
// player.addPlayerListener(this);
System.out.println("44");
player.realize();
player.prefetch();
System.out.println("0000");
vc = (VideoControl) player.getControl("VideoControl");
System.out.println("11111");
  if (vc != null) {
  System.out.println("22222");
  vc.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, MainMidlet.fpi);
  System.out.println("33333");
  // 获取视频的原始大小
  int frameW = vc.getSourceWidth();
  int frameH = vc.getSourceHeight();
  System.out.println("视频宽,高:" + frameW + "," + frameH);
  // 设置视频屏幕坐标,使视频在手机屏幕的左上角显示
  vc.setDisplayLocation(100, 100);
  // 设置视频屏幕大小
  vc.setDisplaySize(frameW, frameH);
  }
currDir.close();
currDir=null;
is.close();
is=null;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
} catch (MediaException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
}
return true;

------解决方案--------------------
少了句 vc.setVisible(true);//显示视频
------解决方案--------------------
你 换其他视频看一下,模拟机支持的视频格式与真机可能不一样
------解决方案--------------------
http://wenku.baidu.com/view/923c5ceb6294dd88d0d26bf5.html 这里有个比较完整的视频播放器的做法希望对你有所帮助
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: