VideoView无法播放视频

时间:2019-03-12 06:02:21

标签: android

我正在尝试使用视频视图播放视频,但我有一个静态视频URL。我无法播放视频,但出现以下两个错误:

03-12 11:24:50.779 25718-26238/com.video E/MediaPlayer: error (1, -38)
03-12 11:24:50.821 25718-26065/com.video E/MediaPlayer: error (1, -2147479552) 

下面的URL现在已更改,但我使用了其他的1 我的编译SDK v是28分钟,SDK是16,目标SDK是28。 Logcat error

      videoBackground = (VideoView) findViewById(R.id.videoViewSplash);
                videoBackground.setOnErrorListener((mp, what, extra) -> false);
                String urll = "https://xxxxx-xxx.xxx.xxxx.xxx/xxxx/540x960.mp4";
                videoBackground.setVideoPath(urll);
                videoBackground.setOnCompletionListener(mp -> videoBackground.seekTo(0));
                videoBackground.start();

2 个答案:

答案 0 :(得分:0)

以此更改您的视频观看功能

   String urll = "https://xxxxx-xxx.xxx.xxxx.xxx/xxxx/540x960.mp4";
  videoBackground.setVideoPath(urll);
  videoBackground.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
                    @Override
                    public void onPrepared(MediaPlayer mp) {
                    videoBackground.start();
                    }
   });

答案 1 :(得分:0)

            //set the uri or path of the video to be played
            videoBackground.setVideoPath(enter your path);
            videoBackground.setVideoURI(enter your uri);

           videoBackground.setOnPreparedListener(new OnPreparedListener() {
             @Override
                public void onPrepared(MediaPlayer mp) {
                    videoViewRelative.start();
                }
            });