Android Video


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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值