gpt4 book ai didi

java - 将java文件更改为android的问题

转载 作者:行者123 更新时间:2023-12-02 00:45:08 25 4
gpt4 key购买 nike

我有一个在netbeans中创建的java项目,现在我试图将其更改为eclipse中的android项目,但它显示了很多错误。请有人帮我解决错误

public abstract class BaseOutputAudioDevice extends AudioDeviceBase {
private Logger log = Logger.getLogger(BaseOutputAudioDevice.class.getName());

protected int position = 0;
protected int freq;
protected int channels;
protected int samplesPerMillisecond;
protected boolean init = false;
protected SampleProcessor processor;

public BaseOutputAudioDevice(SampleProcessor processor) {
this.processor = processor;
}

@Override
protected void openImpl() throws JavaLayerException {
super.openImpl();
}

@Override
protected void writeImpl(short[] samples, int offs, int len) throws JavaLayerException {
if(!init)
{
log.log(Level.INFO, "number of channels: " + getDecoder().getOutputChannels());
log.log(Level.INFO, "number of samples: " + getDecoder().getOutputFrequency());
freq = getDecoder().getOutputFrequency();
channels = getDecoder().getOutputChannels();
samplesPerMillisecond = (freq * channels)/1000;
log.log(Level.INFO, "samples/ms: " + samplesPerMillisecond);
log.log(Level.INFO, "buffer length: " + len);
if(processor != null)
processor.init(freq, channels);
init = true;
}
position += len/samplesPerMillisecond;

outputImpl(samples, offs, len);
}

protected abstract void outputImpl(short[] samples, int offs, int len) throws JavaLayerException;

/**
* Retrieves the current playback position in milliseconds.
*/
public int getPosition() {
log.log(Level.FINE, "position: " + position + "ms");
return position;
}

public SampleProcessor getProcessor() {
return processor;
}

public void setProcessor(SampleProcessor processor) {
this.processor = processor;
}
}

编辑

它显示以下行中的错误

log.log(Level.INFO, "number of channels: " + getDecoder().getOutputChannels());
log.log(Level.INFO, "number of samples: " + getDecoder().getOutputFrequency());
freq = getDecoder().getOutputFrequency();
channels = getDecoder().getOutputChannels();

最佳答案

您正在尝试使用 Android 上不存在的库。例如,您的 log.log 行看起来很像 Log4J 调用。您需要隔离这些行并使用它们的 Android 等效项。在 Log4J 示例中 - 尝试使用 Android 记录器。

关于java - 将java文件更改为android的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5220250/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com