Я пытаюсь воспроизвести файл .mp4, записанный через мое приложение, и я хочу воспроизвести его на VideoView. Я перепробовал много вариантов, и я получаю исключение, в котором говорится, что не удалось открыть файл, за которым следует исключение файла, не найденного. Я установил все свои права доступа к файлам. Есть ли способ, которым я могу сделать это, зная место хранения файла .mp4? Любая помощь будет оценена спасибо заранее. Мой код:
package adi.app.thani;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.MediaController;
import android.widget.VideoView;
import androidx.annotation.Nullable;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
public class Play extends Activity {
MediaPlayer player;
int count;
String talam;
HashMap<Integer, Integer> adi;
HashMap<Integer, Integer> mishra;
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.play);
final FloatingActionButton play = findViewById(R.id.floatingActionButton2);
talam = getIntent().getStringExtra(Intent.EXTRA_INDEX);
count = 0;
mishra = new HashMap<Integer, Integer>();
mishra.put(0, R.mipmap.realhand_foreground);
mishra.put(1, R.mipmap.hello);
mishra.put(2, R.mipmap.hello);
mishra.put(3, R.mipmap.realhand_foreground);
mishra.put(4, R.mipmap.hello);
mishra.put(5, R.mipmap.realhand_foreground);
mishra.put(6, R.mipmap.hello);
mishra.put(7, R.mipmap.seven_foreground);
mishra.put(8, R.mipmap.six_foreground);
mishra.put(9, R.mipmap.five_foreground);
mishra.put(10, R.mipmap.four_foreground);
mishra.put(11, R.mipmap.three_foreground);
mishra.put(12, R.mipmap.two_foreground);
mishra.put(13, R.mipmap.one_foreground);
adi = new HashMap<Integer, Integer>();
adi.put(0, R.mipmap.realhand_foreground);
adi.put(1, R.mipmap.realpinky_foreground);
adi.put(2, R.mipmap.realring_foreground);
adi.put(3, R.mipmap.realmiddle_foreground);
adi.put(4, R.mipmap.realhand_foreground);
adi.put(5, R.mipmap.realturn_foreground);
adi.put(6, R.mipmap.realhand_foreground);
adi.put(7, R.mipmap.realturn_foreground);
adi.put(8, R.mipmap.eight_foreground);
adi.put(9, R.mipmap.seven_foreground);
adi.put(10, R.mipmap.six_foreground);
adi.put(11, R.mipmap.five_foreground);
adi.put(12, R.mipmap.four_foreground);
adi.put(13, R.mipmap.three_foreground);
adi.put(14, R.mipmap.two_foreground);
adi.put(15, R.mipmap.one_foreground);
final VideoView vid = findViewById(R.id.videoView2);
String suffix = getIntent().getStringExtra(Intent.EXTRA_COMPONENT_NAME);
final int bpm = getIntent().getIntExtra(Intent.EXTRA_TEXT,80);
final String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC).getAbsolutePath() + File.separator + suffix + ".mp4";
Uri uri = Uri.parse(path);
vid.setVideoURI(uri);
vid.setMediaController(new MediaController(this));
play.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (count == 0) {
vid.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
vid.start();
}
});
} else {
vid.pause();
}
}
});
vid.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
finish();
}
});
}
protected void onStop() {
super.onStop();
if (player != null) {
player.release();
player = null;
}
}
}
logcat:
04/24 17:41:15: Launching 'app' on motorola moto g(6).
$ adb shell am start -n "adi.app.thani/adi.app.thani.MainActivity" -a
android.intent.action.MAIN -c android.intent.category.LAUNCHER
Connected to process 17612 on device 'motorola-moto_g_6_-ZY322R4GXD'.
Capturing and displaying logcat messages from application. This
behavior can be disabled in the "Logcat output" section of the
"Debugger" settings page.
W/adi.app.thani: Accessing hidden method
Landroid/graphics/drawable/Drawable;-
>getOpticalInsets()Landroid/graphics/Insets; (light greylist, linking)
Accessing hidden field Landroid/graphics/Insets;->left:I (light
greylist, linking)
Accessing hidden field Landroid/graphics/Insets;->right:I (light
greylist, linking)
Accessing hidden field Landroid/graphics/Insets;->top:I (light
greylist, linking)
Accessing hidden field Landroid/graphics/Insets;->bottom:I (light
greylist, linking)
W/System: A resource failed to call close.
I/chatty: uid=10007(adi.app.thani) FinalizerDaemon identical 1 line
W/System: A resource failed to call close.
W/adi.app.thani: Accessing hidden method Landroid/view/View;- >computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist, reflection)
W/adi.app.thani: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (light greylist, reflection)
W/adi.app.thani: Accessing hidden method Landroid/widget/TextView;->getTextDirectionHeuristic()Landroid/text/TextDirectionHeuristic; (light greylist, linking)
D/OpenGLRenderer: Skia GL Pipeline
I/Adreno: QUALCOMM build : dd44a11, I3cb150eb74
Build Date : 02/28/19
OpenGL ES Shader Compiler Version: EV031.25.03.02
Local Branch :
Remote Branch :
Remote Branch :
Reconstruct Branch :
I/Adreno: Build Config : S L 6.0.7 AArch32
I/Adreno: PFP: 0x005ff110, ME: 0x005ff066
I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDispla y retrieved: 0
I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Swap behavior 2
W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@6475b9b
W/MediaPlayer: Couldn't open /storage/emulated/0/Music/Thani64.mp4: java.io.FileNotFoundException: No content provider: /storage/emulated/0/Music/Thani64.mp4
D/MediaPlayerNative: getMetadata`