编译错误:在Android Studio中找不到符号AudioEffect :: setParameter [英] Compile error: Cannot find symbol AudioEffect::setParameter in Android Studio

查看:100
本文介绍了编译错误:在Android Studio中找不到符号AudioEffect :: setParameter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过 AudioEffect :: setParameter 设置 AudioEffect 参数,但是在Android Studio中会出现编译错误.

I'm trying to set AudioEffect parameters by AudioEffect::setParameter, but it gives compile error in Android Studio.

这是我的代码:

import android.media.audiofx.Equalizer;
...
private Equalizer mEqualizer = null;
mEqualizer = new Equalizer(0,  mMediaPlayer.getAudioSessionId());
mEqualizer.setParameter(0,0);

这在我的旧Eclipse项目中起作用;现在我正在使用一个新的AS项目,但出现错误:找不到符号方法setParameter(int,int)

This worked in my old Eclipse project; now I'm using an new AS project, but it gives an error : cannot find symbol method setParameter(int,int)

我还尝试通过AudioEffect对象调用 setParameter():

I also tried call setParameter() by AudioEffect object:

import android.media.audiofx.AudioEffect;

AudioEffect effect = null;
effect = new AudioEffect(AudioEffect.EFFECT_TYPE_EQUALIZER,
                AudioEffect.EFFECT_TYPE_NULL,
                0,
                0);

effect.setParameter(0,0);

然后得到相同的错误.

以下是Android SDK的源代码:

Here are source codes from Android SDK:

android-sdk \ android-23 \ android \ media \ audiofx \ Equalizer.java:

android-sdk\android-23\android\media\audiofx\Equalizer.java:

public class Equalizer extends AudioEffect {

android-sdk \ android-23 \ android \ media \ audiofx \ AudioEffect.java:

android-sdk\android-23\android\media\audiofx\AudioEffect.java:

public class AudioEffect {
...
    public int setParameter(int param, int value) throws IllegalStateException {
        byte[] p = intToByteArray(param);
        byte[] v = intToByteArray(value);
        return setParameter(p, v);
    }

有人知道为什么我不能在Android Studio中调用此方法吗?(但它在Eclipse中有效).

Does anyone know why can't I call this method in Android Studio? (but it works in Eclipse).

Android Studio版本2.1.2使用Android SDK 23(也尝试使用SDK 22和21,出现相同的错误).

Android Studio version 2.1.2 Using Android SDK 23 (also tried SDK 22 and 21, the same error).

推荐答案

按照 AudioManager 具有方法

As per documentation, there is no method setParameters in class AudioEffect, neither there I can see type EFFECT_TYPE_NULL. I checked in my sdk as well. You must be using outdated code. Please refactor it to latest SDK. AudioManager have a method setParamters(String keyValuePairs). It can be of your use.

这篇关于编译错误:在Android Studio中找不到符号AudioEffect :: setParameter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆