【发布时间】:2014-03-17 10:29:42
【问题描述】:
我正在尝试使用 platformRequest() 播放 .mp3 文件。我验证了文件路径,它是正确的。我正在使用诺基亚 210 进行测试。请帮我解决这个问题。
【问题讨论】:
-
你能发布你的代码和异常吗?
标签: java-me media-player nokia nativeapplication
我正在尝试使用 platformRequest() 播放 .mp3 文件。我验证了文件路径,它是正确的。我正在使用诺基亚 210 进行测试。请帮我解决这个问题。
【问题讨论】:
标签: java-me media-player nokia nativeapplication
try {
platformRequest("file:///C:/song.mp3");
} catch (ConnectionNotFoundException ex) {
ex.printStackTrace();
}
我知道您已经验证了是否有文件。虽然检查我下面的代码一次并发表评论与结果。
添加 -
public boolean isFileExisted(String path) {
boolean isExisted = false;
FileConnection filecon = null;
try {
filecon = (FileConnection) Connector.open(path, Connector.READ);
isExisted = filecon.exists();
} catch (java.lang.SecurityException e) {
} catch (Exception e) {
} finally {
try {
if (filecon != null) {
filecon.close();
}
catch (Exception e) {
}
}
return isExisted;
}
}
public void playFileFromSDCard() {
String path1 = "file:///C:/song.mp3";
String path2 = "file:///E:/song.mp3";
if (isFileExisted(path1)) {
try {
System.out.println("path1 exist -> calling platform request " + path1);
platformRequest(path1);
} catch (ConnectionNotFoundException ex) {
ex.printStackTrace();
}
}
else if (isFileExisted(path2)) {
try {
System.out.println("path2 exist -> calling platform request " + path2);
platformRequest(path2);
} catch (ConnectionNotFoundException ex) {
ex.printStackTrace();
}
}
else {
System.out.println("both path doesnt exists");
}
}
【讨论】:
经过多次搜索,我找到了问题的一些原因。这可能对将来遇到同样问题的人有所帮助。请参考以下链接。
Open file with MIDlet.platformRequest() , How to play media file in System media player in j2me????
【讨论】: