Cross platform Xamarin plugin to play and control Audio and Video

License: MIT

Language: C#

Keywords: audio, exoplayer, media, mediamanager, mediaplayer, netstandard, nuget, player, video, xamarin

MediaManager - Cross platform media plugin for Xamarin and Windows

  • Designed to be simple and easy to use
  • Native playback of media files from remote http(s), embedded and local sources
  • Native media notifications and remote controls
  • Queue and playback management by default
  • Playback status (Playing, Buffering, Loading, Paused, Progress)
  • Events for media handling to hook into


Build status GitHub tag NuGet MyGet


  • Feel free to open an issue. Make sure to use one of the templates!
  • Commercial support is available. Integration with your app or services, samples, feature request, etc. Email:
  • Powered by:


More documenatation and information is available on the Wiki



Add the NuGet package to all the projects you want to use it in.

  • In Visual Studio - Tools > NuGet Package Manager > Manage Packages for Solution
  • Select the Browse tab, search for MediaManager
  • Select Plugin.MediaManager
  • Install into each project within your solution

Platform Support

Platform Supported Version Player
.Net Standard Yes 2.0+ MediaManager
Xamarin.Forms Yes 3.2+ MediaManager
Xamarin.Android Yes API 16+ ExoPlayer
Xamarin.iOS Yes iOS 10+ AVPlayer
Xamarin.Mac Yes 3.0+ AVPlayer
Xamarin.tvOS Yes 10.0+ AVPlayer
Tizen Yes 4.0+ MediaPlayer
Windows 10 UWP Yes 10+ MediaPlayer
Windows WPF Yes 4.7.2+ MediaPlayer


Call MediaManager.Current from any .Net library or Xamarin project to gain access to APIs.

IMPORTANT: Initialize plugin

Make sure to call Init() in all the native platforms on startup of your app.


Optionally provide the Activity on Android. This will also be used to bind the Android Service and will be used as Intent to launch from a notification.

public class MainActivity : AppCompatActivity
	protected override void OnCreate(Bundle savedInstanceState)


Play a single media item

await CrossMediaManager.Current.Play("");
await CrossMediaManager.Current.Play("");

Play multiple media items

public IList<string> Mp3UrlList => new[]{

await CrossMediaManager.Current.Play(Mp3UrlList);

Other play possibilities

Task<IMediaItem> Play(IMediaItem mediaItem);
Task<IMediaItem> Play(string uri);
Task<IMediaItem> Play(IEnumerable<IMediaItem> items);
Task<IMediaItem> Play(IEnumerable<string> items);
Task<IMediaItem> Play(FileInfo file);
Task<IMediaItem> Play(DirectoryInfo directoryInfo);
Task<IMediaItem> PlayFromAssembly(string resourceName, Assembly assembly = null);
Task<IMediaItem> PlayFromResource(string resourceName);
  • Playing from a File can be done for example by using the File and Directory api's. You download a file from the internet and save it somewhere using these .NET api's.
  • When playing from Assembly you need to add a media file to a assembly and set the build action to Embedded resource.
  • When playing from a Resource you should add your media file for example to the Assets or raw folder on Android, and the Resources folder on iOS.

For example:

await CrossMediaManager.Current.PlayFromAssembly("somefile.mp3", typeof(BaseViewModel).Assembly);
await CrossMediaManager.Current.PlayFromResource("assets:///somefile.mp3");
await CrossMediaManager.Android.PlayFromResource(Resource.Raw.somefile.ToString());

Control the player

await CrossMediaManager.Current.Play();
await CrossMediaManager.Current.Pause();
await CrossMediaManager.Current.PlayPause();
await CrossMediaManager.Current.Stop();

await CrossMediaManager.Current.StepForward();
await CrossMediaManager.Current.StepBackward();

await CrossMediaManager.Current.SeekToStart();
await CrossMediaManager.Current.SeekTo(TimeSpan position);

Control the Queue

await CrossMediaManager.Current.PlayPrevious();
await CrossMediaManager.Current.PlayNext();
await CrossMediaManager.Current.PlayPreviousOrSeekToStart();
await CrossMediaManager.Current.PlayQueueItem(IMediaItem mediaItem);
await CrossMediaManager.Current.PlayQueueItem(int index);


void ToggleRepeat();
void ToggleShuffle();

Retrieve and set information

Dictionary<string, string> RequestHeaders { get; set; }
TimeSpan StepSize { get; set; }
MediaPlayerState State { get; }
TimeSpan Position { get; }
TimeSpan Duration { get; }
TimeSpan Buffered { get; }
float Speed { get; set; }
RepeatMode RepeatMode { get; set; }
ShuffleMode ShuffleMode { get; set; }
bool ClearQueueOnPlay { get; set; }
bool AutoPlay { get; set; }
bool KeepScreenOn { get; set; }


bool IsPlaying();
bool IsBuffering();
bool IsPrepared();
bool IsStopped();

Properties available on CrossMediaManager.Current.MediaPlayer.*

IVideoView VideoView { get; set; }
bool AutoAttachVideoView { get; set; }
VideoAspectMode VideoAspect { get; set; }
bool ShowPlaybackControls { get; set; }
int VideoHeight { get; }
int VideoWidth { get; }

Hook into events

event StateChangedEventHandler StateChanged;
event BufferedChangedEventHandler BufferedChanged;
event PositionChangedEventHandler PositionChanged;
event MediaItemFinishedEventHandler MediaItemFinished;
event MediaItemChangedEventHandler MediaItemChanged;
event MediaItemFailedEventHandler MediaItemFailed;

Retrieve metadata for media

Depending on the platform and the media item metadata will be extracted from ID3 data in the file.


Since the metadata might not be available immediately you can subscribe for updates like this:

var mediaItem = await CrossMediaManager.Current.Play("");
mediaItem.MetadataUpdated += (sender, args) => {
	var title = args.MediaItem.Title;

Alternatively you could also use the PropertyChanged event to see updates to the metadata.

You can also get a single frame from a video:

string url = "";
var mediaItem = await CrossMediaManager.Current.Extractor.CreateMediaItem(url);
var image = await CrossMediaManager.Current.Extractor.GetVideoFrame(mediaItem, TimeSpan.FromSeconds(1));
ImageSource imageSource = image.ToImageSource();
FormsImage.Source = imageSource;

Add Video Player to the UI

The video view will automatically be attached to the player. If you have multiple video views and you want to hook it up yourself do:

CrossMediaManager.Current.MediaPlayer.AutoAttachVideoView = false;

After that you can manually add the video view like this:

For android we need a VideoView in the axml layout.

	android:layout_height="300dp" />

Then find the view in code:

playerView = view.FindViewById<VideoView>(Resource.Id.your_videoview);

For iOS, MacOS or tvOS we need to add a VideoView either in code, or in a Xib or Storyboard.

var playerView = new VideoView();

Then for all platforms we have to add the player view to the MediaPlayer

CrossMediaManager.Current.MediaPlayer.VideoView = playerView;

Play a non standard format like HLS, Dash or SS

MediaManager will try to make a guess which media type or format is used. Sometimes this will not be picked up or be wrong, but you can enforce it by setting it yourself like this:

var item = await CrossMediaManager.Current.Extractor.CreateMediaItem("");
item.MediaType = MediaType.Hls;

await CrossMediaManager.Current.Play(item);

By enforcing it there is still no guarantee that the native system actually is able to play the item.

Platform specific features

Feature Android iOS, Mac, tvOS UWP Tizen WPF
Media Extraction

You can also directly access the native platform implementation if you need it!

//iOS, MacOS or tvOS


Adding a VideoView to a Page in Forms is easy as this:

<mm:VideoView VerticalOptions="FillAndExpand" Source="" />

Your Xamarin.Forms page could look like this:

<?xml version="1.0" encoding="utf-8" ?>
    x:Class="YourClassName" >
            <mm:VideoView VerticalOptions="FillAndExpand" Source="" ShowControls="False" />

You can even use the normal Play(object) method and not set source. When you navigate to the view that contains the VideoView, the player will automatically attach to the view.

If you want a Page that contains a player you can open the VideoPage.

Navigation.PushAsync(new MediaManager.Forms.VideoPage());

Reactive extensions

Add the Reactive NuGet package to all the projects you want to use it in.



FFmpegMediaMetadataRetriever on Android

If you want to use FFmpegMediaMetadataRetriever on Android to extract the metadata you can set to use this extension like this:

CrossMediaManager.Android.Extractor = new FFmpegMediaExtractor();

Intercept share requests from the native platform or other apps


//Add code to the OnCreate(Bundle savedInstanceState) of your MainActivity
if(await CrossMediaManager.Android.PlayFromIntent(Intent))
    //If true maybe do an action like opening a Player Page.



  • This library will automatically request the following permissions: AccessWifiState, AccessNetworkState, Internet, ForegroundService and WakeLock. You do not need to add them to your AndroidManifest.
  • Your app must target Android SDK v28 or higher
  • This library uses ExoPlayer for video playback. This requires that you enable the following
  • Dex tool to D8: <AndroidDexTool>d8</AndroidDexTool>
  • Optional enable R8 Linker to make code smaller: <AndroidLinkTool>r8</AndroidLinkTool>
  • Aapt2 build tools: <AndroidUseAapt2>true</AndroidUseAapt2>
  • Disable multi-dex when using D8 and R8 with AAPT2. Your code should be small enough with those.


  • In order for the audio to contiunue to play in the background you have to add the 'Audio, Airplay and Picture in Picture Background mode' and 'Background fetch' to your Info.plist
  • If you are playing audio from a http resource you have to take care of ATS. Optionally you can disable this for playing media. Add the following to your info.plist:

If you want to disable more you could add: NSAllowsLocalNetworking or even NSAllowsArbitraryLoads to disable all checks.

  • If you want to display a artwork/cover that is embedded into an MP3 file, make sure that you use ID3 v2.3 (not v2.4).


  • In the Package.appxmanifest under capabilities you need to select: "Background Media Playback", "Internet"
  • Optionally add "Music Library" and "Videos Library" as well if you use that


  • You must request,, and privileges

Building the source code

  • On Windows you need Visual Studio 2019 with the latest Xamarin, .NET Core and UWP installed.
  • On Visual Studio for Mac 2019 multi-target is not supported. Therefor you need to compile from command line on a Mac. Simple go to the folder where the source code is and run: msbuild MediaManager.sln /t:rebuild to make a release build run: msbuild MediaManager.sln /t:rebuild /p:Configuration=Release. To restore your nuget packages run: msbuild MediaManager.sln /t:restore.

Project Statistics

Sourcerank 12
Repository Size 8.93 MB
Stars 467
Forks 233
Watchers 46
Open issues 46
Dependencies 25
Contributors 32
Tags 36
Last updated
Last pushed

Top Contributors See all

Martijn van Dijk Felix Schoeler Erlend Angelsen paulppn Michal Orzechowski Joe Martinez Casper Skoubo Mike Rowley Simon Schick Philipp Tischhauser sjoerd0301 Juanu Jonas BtrJay Andy Joiner Brandon Minnick Tomasz Cielecki Michael Dan Siegel John Thiriet

Packages Referencing this Repo

Cross platform Xamarin plugin to play and control Audio and Video
Latest release 0.8.18 - Updated - 467 stars
Cross platform Xamarin plugin to play and control Audio and Video. This adds Xamarin.Forms specif...
Latest release 0.8.18 - Updated - 467 stars
Cross platform Xamarin plugin to play and control Audio and Video
Latest release 0.8.14 - Updated - 467 stars
Customized XamarinMediaManager
This package is no longer available on NuGet
Package Description
Latest release 1.0.2 - Published - 467 stars
ExoPlayer supports more advanced video and audio playback. This is based on the MediaManager plugin
Latest release 0.4.5 - Updated - 467 stars
Cross platform Xamarin plugin to play Media from PCL. Currently only supports audio playback on A...
Latest release 0.0.1 - Published - 467 stars
Package Description
Latest release - Updated - 467 stars
Package Description
Latest release 1.0.2 - Published - 467 stars
Package Description
Latest release 1.0.2 - Published - 467 stars
Cross platform Xamarin plugin to play and control Audio and Video
Latest release 0.8.14 - Updated - 467 stars
Reactive extensions for MediaManager
Latest release 0.8.14 - Updated - 467 stars

Recent Tags See all

0.8.17 October 17, 2019
0.8.13 October 14, 2019
0.8.12 October 08, 2019
0.8.10 September 25, 2019
0.8.9 September 09, 2019
0.8.5 August 06, 2019
0.8.4 August 06, 2019
0.8.4 August 06, 2019
0.8.1 August 04, 2019
0.7.9 August 01, 2019
0.7.7 July 27, 2019
0.7.6 July 26, 2019
0.7.5 July 26, 2019
0.7.4 July 23, 2019
0.6.9 July 02, 2019

Interesting Forks See all

Cross platform Xamarin plugin to play Media from PCL
C# - MIT - Last pushed - 1 stars

Something wrong with this page? Make a suggestion

Last synced: 2019-10-21 16:59:02 UTC

Login to resync this repository