5

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

And when do I use each one?

Kishor Ramani
  • 607
  • 1
  • 6
  • 12
  • 1
    VideoView is just a wrapper around SurfaceView that plays videos. If you want the gory details, see https://source.android.com/devices/graphics/architecture.html – fadden Jan 28 '16 at 06:08

1 Answers1

3

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.