Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8511633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:03:29+00:00 2026-06-11T04:03:29+00:00

I have a WPF Caliburn.Micro application, and I use MediaPlayer class to play audio.

  • 0

I have a WPF Caliburn.Micro application, and I use MediaPlayer class to play audio. I implemented Play, Stop, and Pause functionality, but I don’t see a method for Resume (after Pause) in MediaPlayer. Could you please help me with this?

Here is some of my code:

       public void Play()
   {
       try
       {
           var audio = Tpv.GetAudio(SelectedTpv.TpvId);
           var file = Path.GetTempFileName().Replace(".tmp", ".wma");
           File.WriteAllBytes(file, audio);

           Player.Open(new Uri(file, UriKind.Absolute));
           Player.Play();
           IsPlaying = true;

       }
       catch (Exception ex)
       {
           MessageBox.Show(String.Format("Failed to play audio:\n{0}", ex.Message), "Failure",
            MessageBoxButton.OK, MessageBoxImage.Error);

           Console.WriteLine(ex.Message);
       }        
   }

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:03:31+00:00Added an answer on June 11, 2026 at 4:03 am

    I’m pretty sure that Play is also supposed to handle resume functionality. According to the MSDN for System.Windows.Media.MediaPlayer the Play method is supposed to “Play media from the current Position”. This means that when you are playing media from the beginning, the position is 0. If you pause, then the media will be paused at a certain position. Pressing play again should resume playback from the same position that you paused the media on.

    Edit:

    Based on the code update you provided, it looks like your issue is that you are loading the file each time you click play. This would cause any previous pause information to be erased, and would treat the file as being brand new each time. You should put some sort of check in there to say that if the file is not already loaded, then load it. Otherwise, your Play method should just call Player.Play() to resume.

    I would also note that you would need to also call Player.Close when you switch the selected item. This would let the Play method know that it needs to load a different file.

    public void Play()
    {
       try
       {
           // Check if the player already has a file loaded, otherwise load it.
           if(Player.Source == null) { 
               var audio = Tpv.GetAudio(SelectedTpv.TpvId);
               var file = Path.GetTempFileName().Replace(".tmp", ".wma");
               File.WriteAllBytes(file, audio);
    
               Player.Open(new Uri(file, UriKind.Absolute));
           }
    
           Player.Play();
           IsPlaying = true;
    
       }
       catch (Exception ex)
       {
           MessageBox.Show(String.Format("Failed to play audio:\n{0}", ex.Message), "Failure",
            MessageBoxButton.OK, MessageBoxImage.Error);
    
           Console.WriteLine(ex.Message);
       }        
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF Caliburn.Micro application, and I want to use System.Window.Media.MediaPlayer to play
In my WPF Caliburn.Micro application, I have a datagrid and a checkbox with a
I have a wpf application using Caliburn.Micro. I need to bind a ListBox to
I have a wpf application using caliburn.micro. It has a datagrid and a combobox.
I have a WPF application with Caliburn.Micro. I want to handle slider's move, i.e.
I have a very interesting problem. I use this technologies in WPF app: Caliburn.Micro
I use caliburn micro and MEF in wpf and I have this problem. I
I have this problem. I use caliburn micro in WPF. In view I have
I have a WPF Caliburn.Micro application. I used to have there a DataGrid, and
In my WPF Caliburn.Micro application, I have a TabControl. I want to be able

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.