Android通过摇晃手机的频率来控制声音的频率(4)
来源:未知 责任编辑:责任编辑 发表时间:2013-11-15 19:49 点击:次
96 audioCount=0;
97 //prvAudioRate=rate;
98 }
99 }
100
101 private void setSensorListener() {
102 Log.i(TAG, "setSensorListener");
103 Sensor sensor = manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
104 manager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_GAME);
105 }
106
107 private void unSensorListener() {
108 Log.i(TAG, "unregisterListener");
109 manager.unregisterListener(this);
110 }
111
112 @Override
113 public void onClick(View v) {
114 switch (v.getId()) {
115 case R.id.hello:
116 setSensorListener();
117 break;
118 default:
119 break;
120 }
121 }
1 /**
2 * @author Stay
3 * 声音管理类
4 */
5 public class SoundManager {
6 public SoundPool mSoundPool;
7 private HashMap<Integer, Integer> mSoundPoolMap;
8 private AudioManager mAudioManager;
9 private Context mContext;
10 private int mStreamID;
11 static final String LOG_TAG = "SoundManager";
12 private boolean mSoundEnable = true;
13 private float mRate = 1f;
14 private boolean playing = false;
15 private int loopMode = 0;
16 private int mPlayIndex = -1;
17
18 public SoundManager(Context mContext) {
19 this.mContext = mContext;
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 进入详细评论页>>