I have a problem with MediaPlayer - I have 4 MP3 files in my res/raw/ folder, and when I build the project, I see 4 different resource id's in R.raw ...
public static final class raw { > > public static final int alarm_1=0x7f050000; > > public static final int car_alarm=0x7f050001; > > public static final int siren_1=0x7f050002; > > public static final int train_crossing=0x7f050003; > > } > However, when I play "different" sounds, the first 3 "different" values all play the same sample (alarm_1). Here's the code I'm using: /*******************************************************************************\ > > |* sound an alarm > > > \*******************************************************************************/ > > public void sound(int alarm) > > { > > if (_sounding) > > return; > > _sounding = true; > > int idx = R.raw.alarm_1; > > Log.w("MP", "alarm = "+alarm); > > switch (alarm) > > { > > case ALARM_SIREN: > > idx = R.raw.siren_1; > > break; > > case ALARM_TRAIN: > > idx = R.raw.train_crossing; > > break; > > case ALARM_CAR: > > idx = R.raw.car_alarm; > > break; > > } > > > Log.w("MP", "Playing resource "+String.format("%x", idx)); > > _player = MediaPlayer.create(_ctx, idx); > > _player.setLooping(true); > > _player.start(); > > } > Now, I can verify that the value of 'alarm' being passed in does vary, and the corresponding value of 'idx' changes as expected. The value of 'idx' being used in MediaPlayer.create(_ctx, idx) corresponds to the defines in the R.raw, as expected. Why, then, does it play the same sample ? If I play the samples from the desktop, they sound different. Just confused as to why android is playing the wrong audio! Simon > > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en