我考虑使用codenameone来实现跨平台应用,Win / Mac / Android / iOS。我在Windows上进行开发,对Mac和iOS开发相当无能为力。我使用的两个特定功能是java.sound API和RandomAccessFile。我很好奇移动平台上对这些的支持是什么样的。以下代码示例是否可以通过codenameone在移动平台(尤其是iOS)上运行?
示例1:
Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();
for (int ii = 0; ii < mixerInfo.length; ii++) {
Mixer mixer = AudioSystem.getMixer(mixerInfo[ii]);
Info[] sli = mixer.getSourceLineInfo();
addSink(sinksModel, sli, mixer);
Info[] tli = mixer.getTargetLineInfo();
addSource(sourcesModel, tli, mixer);
}
}
示例2:
/** Starts playing audio from the current file position. */
public void startPlaying() {
Runnable r = new Runnable() {
@Override
public void run() {
int framePos = sendLastCue();
playing = true;
stopPlaying = false;
while (!stopPlaying) {
try {
int bytes = raf.read(buffer);
if (bytes < 0) {
break;
}
outputLine.write(buffer, 0, bytes);
framePos = sendCues(framePos);
} catch (IOException e) {
e.printStackTrace();
}
}
playing = false;
stopPlaying = true;
for (RecordingListener l : listeners) {
l.playEnded();
}
}
};
new Thread(r).start();
}
示例3:
/* raf is an instance of RandomAccessFile. */
private void writeDirect(byte[] buf, int offset, int length) throws IOException {
flush();
raf.seek(virtualFilePointer);
raf.write(buf, offset, length);
virtualFilePointer = raf.getFilePointer();
virtualLength = Math.max(virtualLength, raf.length());
virtualFilePointer = raf.getFilePointer();
directWriteCount++;
}
谢谢!
答案 0 :(得分:0)
没有
Codename One支持这些平台上的子集,并且不支持其中任何一个。它也不支持NIO或类似的API,这对于本机设备上的QA是不切实际的。
请参阅JavaDocs以获取所支持的API的完整集合:https://www.codenameone.com/javadoc/
您可以通过本机接口访问本机设备功能并以本机方式执行这些操作: http://www.codenameone.com/how-do-i---access-native-device-functionality-invoke-native-interfaces.html
https://www.codenameone.com/manual/advanced-topics.html#_native_interfaces