How can I add equalizer effect to the MediaPlayer, UWP

Shakir Ahmed 25 Reputation points
2023-05-08T19:56:44.0133333+00:00

I have seen how the equalizer effects are added to the audio file/song through AudioGraph. I want to know how the audio effects can be added to the MediaPlayer using this method,

  MediaPlayer.AddAudioEffect();
Universal Windows Platform (UWP)
0 comments No comments
{count} votes

Accepted answer
  1. Junjie Zhu - MSFT 14,751 Reputation points Microsoft Vendor
    2023-05-09T06:50:39.8633333+00:00

    Hi @Shakir Ahmed ,

    Welcome to Microsoft Q&A!

    It is recommended that you refer to the Custom audio effects, use a Windows Runtime component to host your audio effect class.

    After creating the WinRT component according to the documentation, use MediaPlayer.AddAudioEffect to add the audio effect.

    This simple example will mix the current audio sample with a value from the delay buffer according the value of the Mix property.

    // Create a property set and add a property/value pair
    PropertySet echoProperties = new PropertySet();
    echoProperties.Add("Mix", 0.5f);
    // Instantiate the custom effect defined in the 'AudioEffectComponent' project
    AudioEffectDefinition echoEffectDefinition = new AudioEffectDefinition(typeof(ExampleAudioEffect).FullName, echoProperties);
    mediaPlayerElement.MediaPlayer.AddAudioEffect(echoEffectDefinition.ActivatableClassId, true, echoProperties);
    

    Here I use MediaPlayerElement to use MediaPlayer.

    <Grid>
        <MediaPlayerElement x:Name="mediaPlayerElement" Source="ms-appx:///Assets/sample.mp4" AutoPlay="True" />
    </Grid>
    

    Thank you

    Junjie


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful