Play Video

PDF for offline use
Sample Code:
Related SDKs:

Let us know how you feel about this

Translation Quality


0/250

This recipe shows how to play a video using the VideoView class.

Recipe

Follow these steps to play a video.

  1. Add a VideoView to an Xml layout.
<VideoView android:id="@+id/SampleVideoView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
</VideoView>
  1. Obtain a reference to the VideoView in code.
var videoView = FindViewById<VideoView> (Resource.Id.SampleVideoView);
  1. Create an Android.Net.Uri for the video.
var uri = Android.Net.Uri.Parse ("video url goes here");
  1. Pass this Uri to the VideoView.
videoView.SetVideoURI (uri);
  1. Start the VideoView.
videoView.Start ();
  1. Under Project Options, add an Android Manifest. Under Required permissions set the INTERNET permission and press OK.

Additional Information

The VideoView is a convenience class that encapsulates a MediaPlayer and SurfaceView internally.

Xamarin Workbook

If it's not already installed, install the Xamarin Workbooks app first. The workbook file should download automatically, but if it doesn't, just click to start the workbook download manually.