Android Video

来源:互联网 发布:python入门经典pdf下载 编辑:程序博客网 时间:2024/06/06 14:01


http://www.felixjones.co.uk/neo%20website/Android_View/


http://www.jianshu.com/p/d3d3186eefcb

http://www.jianshu.com/p/b2d949ab1a1a

http://www.jianshu.com/p/291ff6ddc164


https://github.com/ChouRay/PlayVideo-OpenGL

https://github.com/yulu/ShaderCam


I can't help you with Unity, but in java, you can create a texture with OpenGL-ES:

private static int GL_TEXTURE_EXTERNAL_OES = 0x8D65;....GLES20.glGenTextures(1, textureHandle, 0);GLES20.glBindTexture(GL_TEXTURE_EXTERNAL_OES, textureHandle[0]);

Use it to create a surface texture and a surface:

SurfaceTexture surfaceTexture = new SurfaceTexture(textureHandle[0]);Surface surface = new Surface(surfaceTexture);

And then pass that surface to android.media.MediaPlayer:

MediaPlayer mediaPlayer = new MediaPlayer(getContext(), uriToMyMediaFile, surface);

Bind that texture to a square in your scene and call this every frame:

surfaceTexture.updateTexImage()

and the video will play when you call mediaPlayer.start();

If Unity allows you to write your own java code to run behind the scenes, this should work if you bind that texture to a surface from Unity.

If you have a video stream that you can't play with mediaPlayer (like a live video chat, etc), you can use the surface with android.media.MediaCodec as well, but there's a lot more setup work involved


这是最简单的一个显示图片的例子

http://m.fx114.net/qa-126-150453.aspx


Rendering SurfaceTexture to Unity Texture2D : http://codegur.com/35227222/rendering-surfacetexture-to-unity-texture2d

0 0