博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
android TextureView有声音没画面&onSurfaceTextureAvailable没调用
阅读量:3974 次
发布时间:2019-05-24

本文共 1163 字,大约阅读时间需要 3 分钟。

如题,这两个问题其实是同一个问题,为什么这么说呢?因为之前获取SurfaceTexture是在onSurfaceTextureAvailable接口里操作的,既然onSurfaceTextureAvailable没回调,获取的SurfaceTexture为空,自然没画面了。

在我的项目升级targetSdkVersion到29之后就会出现,我并不清楚onSurfaceTextureAvailable接口为什么不会执行,不过改完代码后不妨碍项目正常运行就可以了。

查了资料都说要开启硬件加速:android:hardwareAccelerated="true"

卵用没有。

反正在我的小米手机android 10系统上,完全没有效果。

但是调试发现,除了onSurfaceTextureAvailable这个接口没响应,其他接口是正常的,例如onSurfaceTextureUpdated,这就足够了,从onSurfaceTextureUpdated拿SurfaceTexture也一样

@Override    public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width, int height) {        //不再从这里获取到surface        //surface = new Surface(surfaceTexture);    }    @Override    public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int width, int height) {            }    @Override    public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) {        if (surface != null) {            surface.release();        }        return false;    }    @Override    public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {        if (surface == null) {            surface = new Surface(surfaceTexture);        }    }

后续再调用mMediaPlayer.setSurface(surface);就有画面了。

 

 

转载地址:http://harki.baihongyu.com/

你可能感兴趣的文章
Android实现通过浏览器点击链接打开本地应用(APP)并拿到浏览器传递的数据
查看>>
Android音频系统之AudioPolicyService
查看>>
Android系统Root与静默安装
查看>>
Android Property实现介绍
查看>>
Android SystemProperties设置/取得系统属性的用法总结
查看>>
Android 休眠 FLAG_KEEP_SCREEN_ON
查看>>
Android添加onKeyLongPress事件
查看>>
使用微信api将内容分享给好友,或者发送到朋友圈
查看>>
android开发中输入法的弹出和隐藏
查看>>
Android 如何在自定义界面上启用输入法 (How to enable inputmethod for the custom UI)
查看>>
Android MediaCodec小结
查看>>
YUV格式说明
查看>>
MediaCodec and Camera: colorspaces don't match
查看>>
android adb 读写模式 挂载文件系统
查看>>
onTouchEvent方法的使用
查看>>
Android详细解释键盘和鼠标事件
查看>>
如何成为强大的程序员?
查看>>
打包时sun.misc.ServiceConfigurationError
查看>>
摘自 管理自己[Managing Oneself]
查看>>
程序员开发大型应用程序的技巧
查看>>