2015-01-31 2 views
2

목록보기 항목을 기반으로 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(); 
       } 
      } 
     } 
    }); 

enter image description here

답변

2

당신이는 호스트 시스템에서 파일을 여는 데 사용 아무것도 연결하지 않아도은 장치와는 아무 상관이있다.

1

당신은 res 폴더 안드로이드 스튜디오에서 mp3 파일을 드래그 앤 드롭하여 자동으로 검색 할 수 있습니다

관련 문제