How to make TextureView play video with round corners and bubble effect

核能气质少年 提交于 2019-12-01 23:23:24

问题


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);
    ...
    ...
}

Attatch the Surface to MediaPlayer:

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

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:

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?


回答1:


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

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




回答2:


Given that your background is a solid color, you can easily achieve this effect with a mask. If you have any sort of background it wouldn't work though.



来源:https://stackoverflow.com/questions/32217249/how-to-make-textureview-play-video-with-round-corners-and-bubble-effect

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!