O'Reilly logo

Xamarin Studio for Android Programming: A C# Cookbook by Mathieu Nayrolles

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

Playing a movie

As the final recipe of this chapter, we will see how to play a movie with your Android application. Playing video, unlike playing audio, involves some special View elements for displaying it to the users.

Getting ready

For the last time, we will reuse the same project, and more specifically, we will play a video of Mario under the button for playing the Mario theme seen in the previous recipe.

How to do it...

  1. Add the following code to your Main.axml file under the Layout file:
    <VideoView android:id="@+id/myVideoView"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent">
    </VideoView>
  2. As a result, the content of your Main.axml file should look as follows:
  3. Add the following code to the MainActivity.cs class in the OnCreate() ...

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