I am at a loss here. I googled, read other posts concerning the issue with no success.
I need to build an android app that uses ffmpeg for some video decoding. For that I need to access of course videos that are stored on the device. I am trying to open movie files inside the Movies folder. Here is whats inside that folder:
<code>oppen:/ # ls -al storage/emulated/0/Movies/
drwx------ 2 u0_a54 u0_a54 4096 2022-06-20 04:21 .thumbnails
-rw------- 1 u0_a54 u0_a54 77065236 2024-02-20 14:37 Ball_Net_Alpha.mov
-rw------- 1 u0_a54 u0_a54 18809864 2024-03-26 14:33 CityHall_10s_3840x2160_av1_420_60fps_8bit_16000kbps.webm
-rw------- 1 u0_a54 u0_a54 28512971 2024-03-26 11:29 Countdown_3840x2160_30sec_60fps_H265_420_10bit_better.mp4
-rw------- 1 u0_a54 u0_a54 28834060 2024-03-22 09:31 Countdown_3840x2160_30sec_audio_60fps_H265_444_10bit_better.mp4
-rw------- 1 u0_a54 u0_a54 25040410 2024-02-20 14:37 INTRODUCING_BILLABONG_SURF_SERIES.mp4
<code>oppen:/ # ls -al storage/emulated/0/Movies/
total 174116
drwx------ 2 u0_a54 u0_a54 4096 2022-06-20 04:21 .thumbnails
-rw------- 1 u0_a54 u0_a54 77065236 2024-02-20 14:37 Ball_Net_Alpha.mov
-rw------- 1 u0_a54 u0_a54 18809864 2024-03-26 14:33 CityHall_10s_3840x2160_av1_420_60fps_8bit_16000kbps.webm
-rw------- 1 u0_a54 u0_a54 28512971 2024-03-26 11:29 Countdown_3840x2160_30sec_60fps_H265_420_10bit_better.mp4
-rw------- 1 u0_a54 u0_a54 28834060 2024-03-22 09:31 Countdown_3840x2160_30sec_audio_60fps_H265_444_10bit_better.mp4
-rw------- 1 u0_a54 u0_a54 25040410 2024-02-20 14:37 INTRODUCING_BILLABONG_SURF_SERIES.mp4
</code>
oppen:/ # ls -al storage/emulated/0/Movies/
total 174116
drwx------ 2 u0_a54 u0_a54 4096 2022-06-20 04:21 .thumbnails
-rw------- 1 u0_a54 u0_a54 77065236 2024-02-20 14:37 Ball_Net_Alpha.mov
-rw------- 1 u0_a54 u0_a54 18809864 2024-03-26 14:33 CityHall_10s_3840x2160_av1_420_60fps_8bit_16000kbps.webm
-rw------- 1 u0_a54 u0_a54 28512971 2024-03-26 11:29 Countdown_3840x2160_30sec_60fps_H265_420_10bit_better.mp4
-rw------- 1 u0_a54 u0_a54 28834060 2024-03-22 09:31 Countdown_3840x2160_30sec_audio_60fps_H265_444_10bit_better.mp4
-rw------- 1 u0_a54 u0_a54 25040410 2024-02-20 14:37 INTRODUCING_BILLABONG_SURF_SERIES.mp4
I set the correct (according to every post I read) permissions in the manifest file:
<code> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<code> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
</code>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
My code to display the content of the directory looks like this:
<code> String TAG = "#######################################";
File moviesDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES);
String mPath = moviesDir.getAbsolutePath();
Log.d(TAG, "Path to movies: " + mPath);
File[] files = moviesDir.listFiles();
for (File file : files) {
Log.d(TAG, "File: " + file.getName());
Log.d(TAG, "No files found in the Movies directory.");
<code> String TAG = "#######################################";
File moviesDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES);
String mPath = moviesDir.getAbsolutePath();
Log.d(TAG, "Path to movies: " + mPath);
File[] files = moviesDir.listFiles();
if (files != null) {
for (File file : files) {
Log.d(TAG, "File: " + file.getName());
}
} else {
Log.d(TAG, "No files found in the Movies directory.");
}
</code>
String TAG = "#######################################";
File moviesDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES);
String mPath = moviesDir.getAbsolutePath();
Log.d(TAG, "Path to movies: " + mPath);
File[] files = moviesDir.listFiles();
if (files != null) {
for (File file : files) {
Log.d(TAG, "File: " + file.getName());
}
} else {
Log.d(TAG, "No files found in the Movies directory.");
}
Here is now the problem – no matter what permission combination I tried or what code (tried Mediastore and other things) I used to display the directory content I always end up with just:
<code>09-12 11:15:30.336 7886 7886 D #######################################: Path to movies: /storage/emulated/0/Movies
09-12 11:15:30.346 7886 7886 D #######################################: File: .thumbnails
<code>09-12 11:15:30.336 7886 7886 D #######################################: Path to movies: /storage/emulated/0/Movies
09-12 11:15:30.346 7886 7886 D #######################################: File: .thumbnails
</code>
09-12 11:15:30.336 7886 7886 D #######################################: Path to movies: /storage/emulated/0/Movies
09-12 11:15:30.346 7886 7886 D #######################################: File: .thumbnails
My videos never show up. Any Idea what I am doing wrong?
API min version 30
Android 11
x98plus android TV box device