목록보기 항목을 기반으로 mp3 파일을 재생하고 싶습니다. 그러나 내 코드를 기반으로 클릭합니다.이 앱을 실행하면이 창이 나타나고 오디오 옵션이 부족하기 때문에 내 .mp3 파일을 연결하려면이 파일 중 어느 파일을 선택해야하는지 모릅니다.Android Studio에서 .mp3 파일을 연결하는 방법
mainList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
//When clicked, go to specific activity
if (position == 0) {
if(mp.isPlaying())
{
mp.stop();
mp.reset();
}
try {
AssetFileDescriptor afd = getAssets().openFd("chimes.mp3");
mp.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(),afd.getLength());
mp.prepare();
mp.start();
} catch (Exception e) {
e.printStackTrace();
}
}
}
});