gpt4 book ai didi

mp4 - 视频 View : Unable to open content and setDataSource failed

转载 作者:行者123 更新时间:2023-12-04 21:15:07 25 4
gpt4 key购买 nike

我无法使用我的应用程序打开任何视频文件。我从 StackOverFlow 获得了一段代码并使用了它,但它对我不起作用。我的画廊中有链接。但它抛出内容无法打开的运行时错误。但我可以和其他玩家一起玩,顺便说一句,这是用手机拍摄的视频...

public class VideoActivity extends Activity {

private VideoView mVideoView;
String path = "/storage/emulated/0/DCIM/Camera/VID_20151013_150537120.mp4";
//https://www.youtube.com/watch?v=r-M9Xhk026A

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video);
mVideoView = (VideoView) findViewById(R.id.surface_view);
mVideoView.setVideoPath(path);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
mVideoView.start();
//Bundle bundle = getIntent().getExtras();
//String url = bundle.getString("url", "");
//playVideoFromUrl(url);
}

private void playVideoFromUrl(String url) {
mVideoView.setVideoURI(Uri.parse(url));
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
mVideoView.start();
} }

错误日志是:

  I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Enabling debug mode 0
W/art: Suspending all threads took: 13.357ms
W/VideoView: Unable to open content: /storage/emulated/0/DCIM/Camera/VID_20151013_150537120.mp4
W/VideoView: java.io.IOException: setDataSource failed.
W/VideoView: at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1076)
W/VideoView: at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1022)
W/VideoView: at android.media.MediaPlayer.setDataSource(MediaPlayer.java:974)
W/VideoView: at android.widget.VideoView.openVideo(VideoView.java:352)
W/VideoView: at android.widget.VideoView.access$2100(VideoView.java:72)
W/VideoView: at android.widget.VideoView$7.surfaceCreated(VideoView.java:629)
W/VideoView: at android.view.SurfaceView.updateWindow(SurfaceView.java:579)
W/VideoView: at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:176)
W/VideoView: at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:847)
W/VideoView: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1986)
W/VideoView: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1077)
W/VideoView: at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5884)
W/VideoView: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
W/VideoView: at android.view.Choreographer.doCallbacks(Choreographer.java:580)
W/VideoView: at android.view.Choreographer.doFrame(Choreographer.java:550)
W/VideoView: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
W/VideoView: at android.os.Handler.handleCallback(Handler.java:739)
W/VideoView: at android.os.Handler.dispatchMessage(Handler.java:95)
W/VideoView: at android.os.Looper.loop(Looper.java:135)
W/VideoView: at android.app.ActivityThread.main(ActivityThread.java:5312)
W/VideoView: at java.lang.reflect.Method.invoke(Native Method)
W/VideoView: at java.lang.reflect.Method.invoke(Method.java:372)
W/VideoView: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
W/VideoView: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
D/VideoView: Error: 1,0

最佳答案

我尝试了 WRITE_EXTERNAL_STORAGE 和 READ_EXTERNAL_STORAGE 的权限,但没有成功。

就我而言,放置许可证就足够了

<uses-permission android: name = "android.permission.INTERNET" />

关于mp4 - 视频 View : Unable to open content and setDataSource failed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33104383/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com