Custom video controls
The VideoView
is great for displaying videos with a basic set of controls; however, we may require more flexibility and control over how the video is played.
How to do it...
We can play a video onto a SurfaceView
using a MediaPlayer
instance if we need fine control over what we can do or if we want custom video controls:
- First, when using a
SurfaceView
instance, we need to implement theISurfaceHolderCallback
interface, ensuring that we keep track of the surface:public class MainActivity : Activity, ISurfaceHolderCallback { private ISurfaceHolder surfaceHolder; public void SurfaceChanged( ISurfaceHolder holder, Format format, int width, int height) { } public void SurfaceCreated(ISurfaceHolder holder) { surfaceHolder = holder; ...
Get Xamarin Mobile Development for Android Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.