简体   繁体   English

使用opengles,android播放视频

[英]play video using opengles, android

如何在android中使用opengl es播放视频?

Your question is a bit vague. 你的问题有点模糊。 If all you want to do is to play a video in a GL surface, it's possible. 如果您只想在GL曲面中播放视频,那么这是可能的。 See the Media Player sample code that Dave was referring to in his sample. 请参阅Dave在其示例中引用的Media Player示例代码 All you have to do there is to replace the SurfaceView with a GLSurfaceView in both the MediaPlayerDemo_Video.java file as well as in the corresponding layout file (mediaplayer_2.xml). 您所要做的就是在MediaPlayerDemo_Video.java文件以及相应的布局文件(mediaplayer_2.xml)中使用GLSurfaceView替换SurfaceView

Also you need to create a custom Renderer class (one that implements the GLSurfaceView.Renderer interface) and set it to your GLSurfaceView . 您还需要创建一个自定义Renderer类(实现GLSurfaceView.Renderer接口的类)并将其设置为GLSurfaceView

After you do all this, you will have your video playing on a GL surface, but that would be all. 完成所有这些操作后,您将在GL曲面上播放视频,但这就是全部。

If, on the other hand, you want to manipulate the video, ie to draw the video frames in a GL texture and add effects to it or transform it (for example scale, rotate, etc.), then I'm afraid this can't be done. 另一方面,如果你想操纵视频,即在GL纹理中绘制视频帧并向其添加效果或转换它(例如缩放,旋转等),那么我担心这可以不行。 The reason is that you don't have access to the raw video frames in your application. 原因是您无法访问应用程序中的原始视频帧。

I'm not sure why you're metioning OpenGL here, but probably the easiest way to play video is using the VideoView class . 我不确定你为什么在这里提到OpenGL,但可能最简单的播放视频的方法是使用VideoView You'll want to have a look at the MediaPlayer class too. 你也想看看MediaPlayer

You might find the Audio and Video page in the Android Developer Documentation helpful. 您可能会发现Android开发人员文档中音频和视频页面很有帮助。

There's VideoView sample code and MediaPlayer sample code in the API demos provided with the Android SDK. 随Android SDK提供的API演示中有VideoView示例代码MediaPlayer示例代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM