-1
어떻게 res/raw 폴더에 3 개의 mp3 파일의 URI를 가져올 수 있습니까? Uri.parse ("android.resource : //"+ getPackageName() + "/"+ R.raw.splash)하지만 작동하지 않습니다. 제안 사항이 있습니까?res/raw 폴더에 3 개의 mp3 파일의 URI 가져 오기
public void getSongList(){
//query external audio
ContentResolver musicResolver = getContentResolver();
//Uri musicUri = android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
Uri musicUri = Uri.parse("android.resource://com.example.musicplayer/raw/"+R.raw.collide);
Cursor musicCursor = musicResolver.query(musicUri, null, null, null, null);
//iterate over results if valid
if(musicCursor!=null && musicCursor.moveToFirst()){
//get columns
int titleColumn = musicCursor.getColumnIndex
(android.provider.MediaStore.Audio.Media.TITLE);
int idColumn = musicCursor.getColumnIndex
(android.provider.MediaStore.Audio.Media._ID);
int artistColumn = musicCursor.getColumnIndex
(android.provider.MediaStore.Audio.Media.ARTIST);
//add songs to list
do {
long thisId = musicCursor.getLong(idColumn);
String thisTitle = musicCursor.getString(titleColumn);
String thisArtist = musicCursor.getString(artistColumn);
songList.add(new Song(thisId, thisTitle, thisArtist));
}
while (musicCursor.moveToNext());
}
}
확인. 저는 Adroid의 초보자이며 mp3 플레이어를 개발하고 싶습니다. – Rayan
@Rayan : 대부분의 MP3 플레이어는 원시 리소스가 아니라 장치의 기존 오디오 파일에서 작동합니다. 인기있는 검색 엔진에서 'android tutorial'뮤직 플레이어를 검색하면 많은 링크가 나타납니다. – CommonsWare
이 프로젝트는 장치의 오디오 파일에 대해 완벽하게 작동합니다 (http://code.tutsplus.com/tutorials/create-a-music-player-on-android-user-controls--mobile-22787). 원시 리소스에서 기존 오디오로 작업하는 것은 불가능합니다. – Rayan