Video Player App in Xamarin.Forms
Tags: videoplayer, xamarin, xamarinforms
Published: 2019-11-13 17:21:11

---
title: Video Player App in Xamarin.Forms
published: true
date: 2019-06-19 16:12:00 UTC
tags: Video Player,Xamarin,Xamarin.Forms
canonical_url: https://logeshpalani.blogspot.com/2019/06/video-player-app-in-xamarinforms.html
---

### **Introduction  **

                   In this article, we are going to play a video and an audio in Xamarin.Forms application.There is no default function available for playing the video or audio. So, we need to add a plugin for this.

### **Nuget Packages **
_Xamarin.Forms = search "Plugin.MediaManager.Forms"._

_Xamarin.Android = search "Plugin.MediaManager"._

  

  **MediaManager Cross-platform media plugin features**

-  Designed to be simple and easy to play
-  Stand alone for easy integration with existing projects and frameworks
-  Native playback of media files from remote and local sources
-  Native media notifications and remote controls
-  Playback status(Playing, Buffering, Loading, Paused, Progress)  

### **Output 🐱‍👤**

[![](https://1.bp.blogspot.com/-CCEhJv9P53w/XQpWvSY8y1I/AAAAAAAAOPU/4DIthWsxANYpyYz3w1mLMfYRGla7iiwRwCLcBGAs/s320/Video%2BPlayer%2BResult.gif)](https://1.bp.blogspot.com/-CCEhJv9P53w/XQpWvSY8y1I/AAAAAAAAOPU/4DIthWsxANYpyYz3w1mLMfYRGla7iiwRwCLcBGAs/s1600/Video%2BPlayer%2BResult.gif)

  

  

### **Step 1**

You can create Xamarin.Forms app by going to File \>\> New \>\> Visual C# \>\>Cross platform \>\> Cross-platform App (Xamarin.Native or Xamarin.Forms), give the application name, and press OK.  
  
 (Project Name : VideoPlayerApp)

  

[![](https://1.bp.blogspot.com/-WgZeHIdrPEA/XQpW1Cd4aII/AAAAAAAAOPY/_hjca1Fq8EUgZ69V5doprDZ6CMYeOB0vACLcBGAs/s400/Video%2BPlayer%2BNew.png)](https://1.bp.blogspot.com/-WgZeHIdrPEA/XQpW1Cd4aII/AAAAAAAAOPY/_hjca1Fq8EUgZ69V5doprDZ6CMYeOB0vACLcBGAs/s1600/Video%2BPlayer%2BNew.png)

  

  

### **Step 2 :**
             After the project creation, add the following NuGet Packages to your project.

- Plugin.MediaManager
- Plugin.MediaManager.Forms

              For that, go to Solution Explorer and select your solution. Right-click and select Manage NuGet Packages for the Solution". Now, select the following NuGet Package and select your project to install it.

- [Plugin.MediaManager.Forms](https://www.nuget.org/packages/Plugin.MediaManager.Forms/)

### **Step 3 :**
              In this step, add a VideoView control to your project. For that, go to Solution Explorer \>\> VideoPlayerApp (PCL) \>\> double click on MainPage.Xaml. After opening this, you can add VideoView assembly and XAML code to your project.

Write the code as given below.

**Assembly**
  

<script src="https://gist.github.com/logeshpalani98/575eec2e4f87fdd950c4af50a34d4385.js"></script>  

**XAML code**

  

<script src="https://gist.github.com/logeshpalani98/ce23694284ecfd7e8c864119cd9f5870.js"></script>  

### **Step 4 :**

###              Next, open Solution Explorer \>\>VideoPlayerApp(PCL) \>\> MainPage.xaml.cs page and double-click to open its design view. The code is given below.

**Code Behind**
  

  

<script src="https://gist.github.com/logeshpalani98/27526c7e71b19e5d2ab90a12cd4afef2.js"></script>  

### **Step 5 :**

###                Make sure to call "VideoViewRenderer.Init(); "  from your platform code before starting playback, otherwise the video View will not be prepared to display the video.

  

**Android Project**  
Add Android project by going to Solution Explorer \>\> VideoPlayerApp.Droid \>\>MainActivity.cs and double-click to open its design View. Here is the code.  
  

**MainActivity.cs  Code**

  

<script src="https://gist.github.com/logeshpalani98/0050e709ea58559cddcf615d4666adb3.js"></script>  

  

**IOS Project**
 **           ** Add iOS project. For that, go to Solution Explorer \>\> VideoPlayerApp.IOS \>\>AppDelegate.cs and click open AppDelegate.cs. Here is the code for this page.  
  

  

**AppDelegate.cs Code**
  

  

<script src="https://gist.github.com/logeshpalani98/bf36de8b5c860c0f00a7f67cc5cd9a41.js"></script>  

**Universal Windows Project**

                Add Universal Windows project. For that, open Solution Explorer \>\>VideoPlayerApp.UWP \>\> MainPage.xaml.cs and click open MainPage.xaml.cs.
  

**Add the below given code to this page.**  
  

**MainActivity.xaml.cs  code**
  
<script src="https://gist.github.com/logeshpalani98/fdc8662aa596145c4c07a0da2a83b7e2.js"></script>  

### **Step 6 :**

### **              Click ' F5 ' or "Build " to run your projects. Running this project, you will have the result like below.**

**[![](https://1.bp.blogspot.com/-CCEhJv9P53w/XQpWvSY8y1I/AAAAAAAAOPc/qCyGToS_4MA_HpXS0gnjC47-0QS5b72YQCEwYBhgL/s320/Video%2BPlayer%2BResult.gif)](https://1.bp.blogspot.com/-CCEhJv9P53w/XQpWvSY8y1I/AAAAAAAAOPc/qCyGToS_4MA_HpXS0gnjC47-0QS5b72YQCEwYBhgL/s1600/Video%2BPlayer%2BResult.gif)**
  

  

**                   Finally, we have successfully created a Xamarin.Forms VideoPlayerApp Application.**