站内搜索: 请输入搜索关键词

当前页面: 开发资料首页J2ME 专题j2me播放媒体文件时,文件路径应该怎么写?

j2me播放媒体文件时,文件路径应该怎么写?

摘要: j2me播放媒体文件时,文件路径应该怎么写?


程序里面这么写:
myPlayer = Manager.createPlayer("rtsp://150.236.66.85/lee.3gp");
报错:javax.microedition.media.MediaException: Player cannot be created for rtsp://150.236.66.85/lee.3gp

如果媒体文件在本地:
myPlayer = Manager.createPlayer("/dodolook.3gp");
也会报错:Exception: javax.microedition.media.MediaException: malformed locator


如果换一种方式:
如果媒体文件在本地:
InputStream is = getClass().getResourceAsStream("("/dodolook.3gp");
myPlayer = Manager.createPlayer(is, "video/3gpp");
这么写就ok了,就能正常播放了。

但如果读取rtsp的流媒体服务器的文件:
InputStream is = getClass().getResourceAsStream("rtsp://150.236.66.85/lee.3gp");
myPlayer = Manager.createPlayer(is, "video/3gpp");
也会报错:Exception: java.lang.IllegalArgumentException



这是什么原因,到底该怎么读取rtsp的流媒体服务器的文件呢?



使用HttpConnection试试,我没有写过,常试下

HttpConnection c = null;
c = ( HttpConnection ) Connector.open("rtsp://150.236.66.85/lee.3gp");
DataInputStream is = c.openDataInputStream();


我晕,看了下好象不支持流媒体的说,楼主可以用http连接吧,用http上面的方法就可以了


知道原因了,模拟器有问题,放在手机上就可以了。


↑返回目录
前一篇: 新手求教问题(关于方块上下左右移动)
后一篇: 数据库文件打包的问题(在线等待)