以前没有尝试过,但我认为你可以使用完全免费的 vlcj 框架,并且可以有效地播放几乎任何类型的视频(当然也可以播放 .mp4 视频文件)。我不能在 android 中给你任何代码,因为从来没有与android一起工作,但我知道java并且它只是工作。所以这里是我在Java中使用的:
NativeLibrary.addSearchPath("libvlc",path); //To set path of libvlc
Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);//To import libvlc
//The path can be a folder in your android project.All the files needed are in vlc player installation folder.so yes you have to install vlc in your computer to get those files but just once.
canvas = new WindowsCanvas();
panel.add(canvas);//panel is like your VideoView
canvas.setVisible(true);
canvas.setBackground(Color.black);
mediaPlayerFactory = new MediaPlayerFactory();
player12 = mediaPlayerFactory.newEmbeddedMediaPlayer();
CanvasVideoSurface videoSurface = mediaPlayerFactory.newVideoSurface(canvas);
player12.setVideoSurface(videoSurface);
player12.setPlaySubItems(true);
player12.startMedia(yourVideoPath);
player12.setAspectRatio(""+panel.getWidth()+":"+panel.getHeight()); //Those two lines are for your video to be adusted in your panel or better to your VideoView
player12.setCropGeometry(""+panel.getWidth()+":"+panel.getHeight());
您必须包含在类路径中的 jar 文件是 jna-3.4.0.jar,platform-3.4.0.jar,vlcj-2.1.0.jar