Error creating Media Player; Java, Android Studio

Well i know, that there are 2 results of MediaPlayer.create() function: created stream or null, and in this case i get the second one result. Got some thoughts about file path, but still don't know where i'm wrong. (Trying to play a random track from assets folder). Thanks in advance!

int itemIndex = (int) (Math.random() * listOfFiles.length);

String file = listOfFiles[itemIndex];

String filePath = "file:///android_asset/".concat(file);

Uri uri = Uri.parse(filePath);

final MediaPlayer mediaPlayer = MediaPlayer.create(MainActivity.this, uri);...

Read More »

By: StackOverFlow - 5 days ago

Related Posts