Weird frames appear when using TextureView to play

2019-02-26 21:55发布

问题:

I managed to play multiple videos in one screen circularly, I added TextureViews to ListView with BaseAdapter which is very common and I created a IjkMediaPlayer (IjkMediaplay github)instance for each textureview. I have reused textureview in getView() callback of BaseAdapter, once getView() called, I stop the previous video and play the new video.

This works fine in most of time, but occasionally, TextureView will display some frames which is not belong to the current video, the frames display for very short time during the playback just like a flash.

With effort, I finally found where the strange frames come, they are from the video which is playing outside of the screen. The weird frames will not appear if I push up the listview to make the outside textureview show up.

I have record a video to show the scene, in the video you will see 2 videos are playing circularly and a weird frame appear occasionally. I assert that the weird frame(a white phone on the desk in the frame) is from the video below which is playing outside the screen. click to download the video

Is this a bug of TextureView on Android, and how to avoid the weird playing? Who can give me some advices?