我正在尝试在android中重现视频,但此代码不适用于Android Lollipop帮助,请尝试以下操作:

        String videopath = "android.resource://com.example.video/"+R.raw.a;
        Uri vidUri = Uri.parse(videopath);
        videoView = findViewById(R.id.videoView);
        videoView.setVideoURI(vidUri);
        videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            public void onPrepared(MediaPlayer mp) {
                             videoView.start();
            }
        });


这是错误:

03-02 23:09:50.923 8141-8158/com.example.video E/MediaPlayer: error (1, -38)
03-02 23:09:50.923 8141-8157/com.example.video E/MediaPlayer: error (1, -38)
03-02 23:09:50.936 8141-8141/com.example.video E/MediaPlayer: start called in state 0
03-02 23:09:50.936 8141-8141/com.example.video E/MediaPlayer: error (-38, 0)
03-02 23:09:50.967 8141-8141/com.example.video E/MediaPlayer: Error (1,-38)
03-02 23:09:50.967 8141-8141/com.example.video D/VideoView: Error: 1,-38
03-02 23:09:50.977 8141-8141/com.example.video E/MediaPlayer: Error (1,-38)
03-02 23:09:50.978 8141-8141/com.example.video D/VideoView: Error: 1,-38
03-02 23:09:50.987 8141-8141/com.example.video E/MediaPlayer: Error (-38,0)
03-02 23:09:50.987 8141-8141/com.example.video D/VideoView: Error: -38,0

最佳答案

我解决了这个问题,是使用棒棒糖和旧版本的视频格式,我需要使用诸如Handbrake之类的工具使用基准H.264配置文件对视频进行重新编码。

09-25 19:37