#2642·uno

Support for `MediaPlayerElement`/`MediaPlayer`

Author: sonnemafCreated Feb 12, 2020Updated Sep 18, 2026
Labelsplatform/wasm 🌐platform/android 🤖platform/ios 🍎project/media 📺no-repro

What would you like to be added:

Windows.UI.Xaml.Controls.MediaPlayerElement and/or Windows.Media.Playback.MediaPlayer

Why is this needed:

I'm currently converting an UWP game (Minesweeper 10) to Uno. This game should play sounds. I would love to play them using an MediaPlayerElement or MediaPlayer.

I use the following SoundHelper to play my sounds. It works currently in UWP only.

Related issues

Support issues

Other issues

All targets

iOS/Android

Android

iOS

Mac Catalyst

Wasm/Skia

Wasm/iOS

Wasm

Skia

Example

using System;
using Windows.Media.Core;
using Windows.UI.Xaml.Controls;

namespace Minesweeper.Helpers {

    static class SoundHelper {

        public static MediaPlayerElement Player { get; set; } = new MediaPlayerElement();

        public static bool IsMuted { get; set; }

        public static void Play(Sound sound, double volume = 1D) {
            if (!IsMuted) {
                switch (sound) {
                    case Sound.Gameover:
                        Player.Source = MediaSource.CreateFromUri(new Uri("ms-appx:///Assets/Sounds/Yeah.wav"));
                        break;
                    case Sound.Explode:
                        Player.Source = MediaSource.CreateFromUri(new Uri("ms-appx:///Assets/Sounds/Explode.mp3"));
                        break;
                    default:
                        break;
                }
                Player.MediaPlayer.Volume = volume;
                Player.MediaPlayer.Play();
            }
        }

    }

    public enum Sound {
        Gameover,
        Explode,
    }
}

For which Platform:

  • iOS
  • Android
  • WebAssembly
  • WebAssembly renderers for Xamarin.Forms
  • macOS
  • Windows
  • Build tasks
  • Solution Templates

Anything else we need to know?