Since recently I'm using the OPUS file format in my music library. Even though Android seems to support the OPUS file format natively there are not many music players listing music tracks encoded in this format.
I've wanted to create my own simple music player listing OPUS encoded audio tracks. However I couldn't figure out how to find the files on the system.
The best way would be to use a query/cursor. However OPUS files are just ignored:
Cursor cursor = getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
null, null, null, null);
System.out.println(cursor.getCount()); //The size of my music library without .opus files
while (cursor.moveToNext()) {
//.mp3 and .flac files but no .opus files
System.out.println(cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.DISPLAY_NAME)));
}
Then I tried to access my music files manually but without success:
File musicDirectory = new File(getExternalFilesDir(Environment.DIRECTORY_MUSIC).toURI());
//This directory seems to be empty, length: 0
System.out.println(musicDirectory.list().length);
And:
File file = new File(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI.getPath());
//Exists: false
System.out.println(file.exists());
Has anybody got any idea what the problem is, or know any workarounds? Any help would be appreciated.