
This fixes some small niggles: 1. `inferContentType(String)` is documented to take a path, but in the tests we're passing full URIs. 2. A `String` parameter is usually a path, but also a MIME type or an extension. In the new methods, the meaning of a `String` parameter is always clear from the name of the method. 3. `inferContentType(String)` is always passed an extension in 'production' code (which has to be manually prefixed with a dot). 4. `inferContentType(Uri, @Nullable String)` always ignores the Uri if the String is non-null. IMO this logic is clearer to a reader if it's just in-lined at the call-site. These methods are used from the demo apps, so will be part of the stable API. PiperOrigin-RevId: 444826053
ExoPlayer SurfaceControl demo
This app demonstrates how to use the SurfaceControl API to redirect video
output from ExoPlayer between different views or off-screen. SurfaceControl
is new in Android 10, so the app requires minSdkVersion
29.
The app layout has a grid of SurfaceViews
. Initially video is output to one
of the views. Tap a SurfaceView
to move video output to it. You can also tap
the buttons at the top of the activity to move video output off-screen, to a
full-screen SurfaceView
or to a new activity.
When using SurfaceControl
, the MediaCodec
always has the same surface
attached to it, which can be freely 'reparented' to any SurfaceView
(or
off-screen) without any interruptions to playback. This works better than
calling MediaCodec.setOutputSurface
to change the output surface of the codec
because MediaCodec
does not re-render its last frame when that method is
called, and because you can move output off-screen easily (setOutputSurface
can't take a null
surface, so the player has to use a DummySurface
, which
doesn't handle protected output on all devices).
See the demos README for instructions on how to build and run this demo.