如何在ExoPlayer的PlayerView中使用TextureView而不是SurfaceView? [英] How to use TextureView instead of SurfaceView with PlayerView of ExoPlayer?

查看:523
本文介绍了如何在ExoPlayer的PlayerView中使用TextureView而不是SurfaceView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道可以在ExoPlayer中使用TextureView.但是我找不到任何有关如何以适当方式实现此功能的示例.您能帮我解决这个问题吗?

I know it is possible to use TextureView in ExoPlayer. But I cannot find any sample on how to implement this functionality in a proper way. Could you please help me on this issue?

推荐答案

PlayerView具有xml属性surface_type,可让您选择要使用SurfaceView还是TextureView.

The PlayerView has an xml attribute surface_type which let's you choose whether you want to use a SurfaceView or a TextureView.

(注意:SimpleExoPlayerView在最近的版本中已重命名为PlayerView,因为它仅取决于Player接口,而不再取决于SimpelExoPlayerView.)

(Note: SimpleExoPlayerView has been renamed to PlayerView in recent versions since it only depends on the Player interface and not on SimpelExoPlayerView anymore.)

您可以选择texture_view,surface_view(默认)或不选择.请参见 PlayerView JavaDoc的主要部分以获得详细信息.

You can choose texture_view, surface_view (default) or none. See the main section of the JavaDoc of PlayerView for details.

<com.google.android.exoplayer2.ui.PlayerView android:id="@+id/player_view"
     app:surface_type="texture_view"
     android:layout_width="match_parent"
     android:layout_height="match_parent"/>

这篇关于如何在ExoPlayer的PlayerView中使用TextureView而不是SurfaceView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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