如何使TextureView播放带有圆角和气泡效果的视频 [英] How to make TextureView play video with round corners and bubble effect

查看:948
本文介绍了如何使TextureView播放带有圆角和气泡效果的视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设法在Android上使用TextureView和MediaPlayer播放视频.我这样做是这样的: 我用SurfaceTexture创建了一个Surface:

I managed to play video with TextureView and MediaPlayer on Android. I did it like this: I created a Surface with SurfaceTexture:

    public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int w, int h)
{
    mSurface = new Surface(surfaceTexture);
    ...
    ...
}

将Surface附加到MediaPlayer:

Attatch the Surface to MediaPlayer:

    try
{
    mMediaPlayer.setDataSource(mPlayUrl);
    mMediaPlayer.setSurface(mSurface);
    ...
    ...
}

可以,但是对我来说还不够.我希望TextureView具有圆角并且看起来像一个气泡(有一个角度),请看下面的图片:

That is OK, but not enough for me. I expect that the TextureView to be with round corners and look like a bubble(with an angle), look at the picture below:

我找到了一篇文章( Android上的圆形视频角)很有帮助,但是作者选择了GLSurfaceView并仅实现了圆角.我相信TextureView也适合​​实现我的效果,SurfaceTexure处理是关键.但是我对opengl不熟悉,谁能给我一些建议?

I found an article(Round video corners on Android) which is very helpful, but the author chose GLSurfaceView and only implemented round corners. I believe that TextureView is also suitable for implementing my effect, SurfaceTexure processing is the key.But I am not familiar with opengl, Who can give me some advices?

推荐答案

我知道答复很晚,但是如果仍然有人难以找到示例下面的解决方案,可能会有所帮助. https://github.com/developer-anees/android-round-camera2video-预览

I know it's late reply, but if anyone still struggle to finds solution below sample may help. https://github.com/developer-anees/android-round-camera2video-preview

尝试此示例.它以圆圈显示相机预览.基本上,它使用FrameLayout作为父级以圆形显示Textureview.

Try this sample. It display camera preview in circle. Basically it use FrameLayout as parent to display Textureview in circle.

这篇关于如何使TextureView播放带有圆角和气泡效果的视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆