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 8317495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:37:22+00:00 2026-06-08T21:37:22+00:00

I’m working with some Audio files in my app (mp3, wav, ..etc) I was

  • 0

I’m working with some Audio files in my app (mp3, wav, ..etc)
I was using the MediaPlayer class from the System.Windows.Media namespace..
but I had some problems with computing the duration of the sound file,
my form is actually a small media player, it has a TrackBar a ComboBox
and the normal next, previous and play buttons ..
I used this code to get the duration of the sound file to determine the maximum value of the track bar:

private void MusicComboBox_SelectedIndexChanged(object sender, EventArgs e)
{   
  System.Windows.Duration duration = Player.NaturalDuration;
  SeekBar.Value = 0;
  Player.Open(new Uri(soundEffectPackage.GetMusicAt(MusicComboBox.SelectedIndex)));
  if(duration.HasTimeSpan)
    SeekBar.Maximum = duration.TimeSpan.Seconds;  
}

This is working fine with only some of the files,
while other files don’t have a TimeSpan so the if isn’t getting executed, and if i removed the if, I’ll get an exception saying that I should check first to see if the HasTimeSpan is true, then moving on.

How can i fix this?
How can i get the duration of the audio file ?
And what do they mean by a time span ?

Any help would be appreciated, thank you 🙂

  • 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-08T21:37:25+00:00Added an answer on June 8, 2026 at 9:37 pm

    According This

    You need to wait for MediaOpened event to fire, NaturalDuration will be available after that. To check if value is available, you can use NaturalDuration.HasTimeSpan property.

    but the best chose for working with audio and video file is “Fmod.dll”.this have a lot of Privilege to work with audio file

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
We're building an app, our first using Rails 3, and we're having to build
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have thousands of HTML files to process using Groovy/Java and I need to
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a bunch of posts stored in text files formatted in yaml/textile (from
I'm using an ASP request returning a XML file containing some latin characters. By
I am using jsonparser to parse data and images obtained from json response. When
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.