Stay organized with collections
Save and categorize content based on your preferences.
This page describes the different types of surfaces that can be used for video
playback with Media3, and how to choose the right type for your use case. To
find out more about Surface objects in Android, read this graphics
documentation.
Choose a surface type for PlayerView
The surface_type attribute of PlayerView lets you set the type of
surface used for video playback. The allowed values are:
video_decoder_gl_surface_view (VideoDecoderGLSurfaceView) - video
rendering using extension renderers
none - which is for audio playback only and should be used to avoid having
to create a surface because doing so can be expensive.
If the view is for regular video playback then surface_view or texture_view
should be used. SurfaceView has a number of benefits over
TextureView for video playback:
More accurate frame timing, resulting in smoother video playback.
Support for higher quality HDR video output on capable devices.
Support for secure output when playing DRM-protected content.
The ability to render video content at the full resolution of the display on
Android TV devices that upscale the UI layer.
SurfaceView should therefore be preferred over TextureView where possible.
TextureView should be used only if SurfaceView does not meet your needs. One
example is where smooth animations or scrolling of the video surface is required
prior to Android 7.0 (API level 24), as described in the following notes. For
this case, it's preferable to use TextureView only when SDK_INT is less
than 24 (Android 7.0) and SurfaceView otherwise.
Media3 ui-compose module provides a PlayerSurface Composable that links
the Player to a Surface in a lifecycle-aware manner. The surface types
in this case are:
There is no type none, since that would correspond to not including the
PlayerSurface in your Compose UI tree.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-03-26 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-03-26 UTC."],[],[]]