1*30877f79SAndroid Build Coastguard Worker# ExoPlayer SurfaceControl demo 2*30877f79SAndroid Build Coastguard Worker 3*30877f79SAndroid Build Coastguard WorkerThis app demonstrates how to use the [SurfaceControl][] API to redirect video 4*30877f79SAndroid Build Coastguard Workeroutput from ExoPlayer between different views or off-screen. `SurfaceControl` 5*30877f79SAndroid Build Coastguard Workeris new in Android 10, so the app requires `minSdkVersion` 29. 6*30877f79SAndroid Build Coastguard Worker 7*30877f79SAndroid Build Coastguard WorkerThe app layout has a grid of `SurfaceViews`. Initially video is output to one 8*30877f79SAndroid Build Coastguard Workerof the views. Tap a `SurfaceView` to move video output to it. You can also tap 9*30877f79SAndroid Build Coastguard Workerthe buttons at the top of the activity to move video output off-screen, to a 10*30877f79SAndroid Build Coastguard Workerfull-screen `SurfaceView` or to a new activity. 11*30877f79SAndroid Build Coastguard Worker 12*30877f79SAndroid Build Coastguard WorkerWhen using `SurfaceControl`, the `MediaCodec` always has the same surface 13*30877f79SAndroid Build Coastguard Workerattached to it, which can be freely 'reparented' to any `SurfaceView` (or 14*30877f79SAndroid Build Coastguard Workeroff-screen) without any interruptions to playback. This works better than 15*30877f79SAndroid Build Coastguard Workercalling `MediaCodec.setOutputSurface` to change the output surface of the codec 16*30877f79SAndroid Build Coastguard Workerbecause `MediaCodec` does not re-render its last frame when that method is 17*30877f79SAndroid Build Coastguard Workercalled, and because you can move output off-screen easily (`setOutputSurface` 18*30877f79SAndroid Build Coastguard Workercan't take a `null` surface, so the player has to use a `DummySurface`, which 19*30877f79SAndroid Build Coastguard Workerdoesn't handle protected output on all devices). 20*30877f79SAndroid Build Coastguard Worker 21*30877f79SAndroid Build Coastguard WorkerSee the [demos README](../README.md) for instructions on how to build and run 22*30877f79SAndroid Build Coastguard Workerthis demo. 23*30877f79SAndroid Build Coastguard Worker 24*30877f79SAndroid Build Coastguard Worker[SurfaceControl]: https://developer.android.com/reference/android/view/SurfaceControl 25