O'Reilly logo

Xamarin Mobile Development for Android Cookbook by Matthew Leibowitz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

  1. First, when using a SurfaceView instance, we need to implement the ISurfaceHolderCallback 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; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required