onSurfaceTextureAvailable in VideoView is never called...
I have this view that is holding the textureview.
public class MyMediaPlayer extends RelativeLa
As for me ,the key to solve the problem is that add android:hardwareAccelerated="true" for the activity in the AndroidManifest.xml .
You can use TextureView in a Scrolling-Container(Such as ListView,ScrollView,ViewPager etc) only if the activity for the TextureView with hardwareAccelerated property on.
The last few words in this blog mentioned that
Hope it works for you.
try to put mTextureView.setSurfaceTextureListener() in onCreate().
RootCause is that: onCreate() -> drawUI -> getHardwareLayer() -> callback SurfaceTextureListener.
So to fix this issue: setSurfaceTextureListener() before UI draw or redraw the UI.
onSurfaceTextureAvailable doesn't seem to get called if the SurfaceTexture is already available. You can check if it is available and call your onSurfaceTextureAvailable method like below.
textureView.setSurfaceTextureListener(this);
/*
* onSurfaceTextureAvailable does not get called if it is already available.
*/
if (view.isAvailable()) {
onSurfaceTextureAvailable(view.getSurfaceTexture(), view.getWidth(), view.getHeight());
}
i had the same problem , strangely resolved it with the following code
videoPreview = (TextureView) linearLayout.findViewById(R.id.videoView);
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams)videoPreview.getLayoutParams();
params.height = 130;
params.width = 508;
videoPreview.setLayoutParams(params);
videoPreview.setSurfaceTextureListener(this);
More strangely if i set only the width or the height that dosent work either.
In my case I initially had my TextureView invisible and then loaded after fetching some data and this was causing onSurfaceTextureAvailable not to be called. I am guessing that for TextureView to be said to be 'available', it must be visible. My solution was to just make the TextureView visible from the start.
I have met the same issue, onSurfaceTextureAvailable never called. Finally I found my textureview is invisible before setSurfaceTextureListener. So check status of textureview at first.