none
Playing a *.MP3 file in WPF ?

Answers

  • It is simple to play a mp3 file using MediaElement control in WPF.

    XAML Code:

    <MediaElement Height="120" Margin="10,10,108,0" LoadedBehavior="Manual" Name="mediaElement1" VerticalAlignment="Top" />

    C# Code:
           private void Window_Loaded(object sender, RoutedEventArgs e)
            {
                mediaElement1.Source=new Uri("D:\\Songs\\Apple.mp3");
                mediaElement1.Play();
            }

    Let me know this is what you are looking for.

    Thanks
    Prasanna

    • Marked as answer by _Hasti_ Wednesday, December 03, 2008 12:42 PM
    Tuesday, December 02, 2008 1:54 PM
  • Do you try with the SoundPlayer class ??
    • Marked as answer by _Hasti_ Wednesday, December 03, 2008 12:46 PM
    Tuesday, December 02, 2008 2:23 PM

All replies

  • It is simple to play a mp3 file using MediaElement control in WPF.

    XAML Code:

    <MediaElement Height="120" Margin="10,10,108,0" LoadedBehavior="Manual" Name="mediaElement1" VerticalAlignment="Top" />

    C# Code:
           private void Window_Loaded(object sender, RoutedEventArgs e)
            {
                mediaElement1.Source=new Uri("D:\\Songs\\Apple.mp3");
                mediaElement1.Play();
            }

    Let me know this is what you are looking for.

    Thanks
    Prasanna

    • Marked as answer by _Hasti_ Wednesday, December 03, 2008 12:42 PM
    Tuesday, December 02, 2008 1:54 PM
  • Do you try with the SoundPlayer class ??
    • Marked as answer by _Hasti_ Wednesday, December 03, 2008 12:46 PM
    Tuesday, December 02, 2008 2:23 PM
  • Mariano O. Rodriguez said:

    Do you try with the SoundPlayer class ??


    Thank you very much Mariano.
    Wednesday, December 03, 2008 12:46 PM
  • I actually have been having some trouble using the mp3 files,I converted also to .wav, still didn't work, I'll try that out and see how it works.

    Thanks.

    Thursday, July 17, 2014 9:36 AM
  • Yes, it worked!
    Thursday, July 17, 2014 9:57 AM