mp3 track duration

Duarte Vinagre 60 Reputation points
2023-07-13T14:59:53.1866667+00:00

hello...can someone drop an idea? i would like to get my mp3 duration using WindowsMediaPlayer module/control?!

i know these will be just a few lines of code...but crucial for my small app :)

Thanks!

Developer technologies | C#
{count} votes

2 answers

Sort by: Most helpful
  1. Castorix31 90,696 Reputation points
    2023-07-13T15:44:52.93+00:00

    For example :

    WindowsMediaPlayer wmp;
    wmp = new WindowsMediaPlayer();
    IWMPMedia pMedia = wmp.newMedia(@"E:\01. IMANY - Don't Be so Shy (Filatov & Karas Remix).mp3");
    wmp.currentPlaylist.appendItem(pMedia);
    System.Diagnostics.Debug.WriteLine("Duration : {0} ({1})", pMedia.durationString, pMedia.duration);
    wmp.settings.volume = 50;
    wmp.controls.play();
    
    0 comments No comments

  2. Duarte Vinagre 60 Reputation points
    2023-07-13T15:48:46.82+00:00

    i was able with this..Thanks :)

      WMPLib.IWMPMedia media = this.player.newMedia(folderBrowserDialog1.SelectedPath+ "\\" + listbox1.SelectedItem);
                    lblduration.Text = (string.Format("{1}", media.sourceURL, media.durationString));
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.