以前没有尝试过,但我认为您可以使用完全免费的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