Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between VideoView and TextureView and Suraceview in android?

What's the difference between VideoView and TextureView and Suraceview in android?

And when do I use each one?

like image 201
Kishor Ramani Avatar asked Oct 18 '22 17:10

Kishor Ramani


1 Answers

Sorry for the late answer, just stumbled upon this but the TL;DR answer is this:

VideoView -> VideoView extends SurfaceView and is essence just SurfaceView + MediaPlayer. The dismantling of the surface and MediaPlayer and such is taken care of by the widget for your convenience.

SurfaceView-> According to Android Developer:

Provides a dedicated drawing surface embedded inside of a view hierarchy. You can control the format of this surface and, if you like, its size; the SurfaceView takes care of placing the surface at the correct location on the screen

The surface is Z ordered so that it is behind the window holding its SurfaceView; the SurfaceView punches a hole in its window to allow its surface to be displayed

What this means is that it takes info from the view hierarchy to create a dedicated drawing area hooked up to the GPU. The drawback of which means no fancy view stuff such as animations and transitions. But more performant

TextureView -> From Android Developer:

Unlike SurfaceView, TextureView does not create a separate window but behaves as a regular View. This key difference allows a TextureView to be moved, transformed, animated, etc

And there you have it, the drawback of a TextureView means that, due to it being part of your view hierarchy, it will redraw it self during the view passes thus costing more resources, but you will have animations, transitions, alpha etc.

like image 148
Mohsen Farzone Avatar answered Oct 21 '22 12:10

Mohsen Farzone