简体   繁体   English

如何使TextureView播放具有圆角和气泡效果的视频

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

I managed to play video with TextureView and MediaPlayer on Android. 我设法在Android上使用TextureView和MediaPlayer播放视频。 I did it like this: I created a Surface with SurfaceTexture: 我是这样做的:我用SurfaceTexture创建了一个Surface:

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

Attatch the Surface to MediaPlayer: 将Surface连接到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: 我希望TextureView与圆角一起看起来像一个气泡(有一个角度),请看下图: 效果我期待

I found an article( Round video corners on Android ) which is very helpful, but the author chose GLSurfaceView and only implemented round corners. 我发现了一篇文章( Android上的圆形视频角落 )非常有用,但作者选择了GLSurfaceView并且只实现了圆角。 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? 我相信TextureView也适合​​实现我的效果,SurfaceTexure处理是关键。但我不熟悉opengl,谁能给我一些建议?

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. 如果你有任何背景,它将无法工作。

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

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