【问题标题】:platformRequest not working in J2ME平台请求在 J2ME 中不起作用
【发布时间】:2014-03-17 10:29:42
【问题描述】:

我正在尝试使用 platformRequest() 播放 .mp3 文件。我验证了文件路径,它是正确的。我正在使用诺基亚 210 进行测试。请帮我解决这个问题。

【问题讨论】:

  • 你能发布你的代码和异常吗?

标签: java-me media-player nokia nativeapplication


【解决方案1】:
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");
    }
}

【讨论】:

【解决方案2】:

经过多次搜索,我找到了问题的一些原因。这可能对将来遇到同样问题的人有所帮助。请参考以下链接。

Open file with MIDlet.platformRequest() , How to play media file in System media player in j2me????

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-04
    • 1970-01-01
    • 2023-02-07
    • 1970-01-01
    • 2021-12-22
    • 2014-10-05
    相关资源
    最近更新 更多