You must Sign In to post a response.
  • Category: ASP.NET

    Windows WindowsMediaPlayer duration not working in c#

    i Try .net framework 4.0, and print duration of the video

    file. But the below code display 00:00.

    String FileDuration2 = "";
    WMPLib.WindowsMediaPlayer wmp = new WMPLib.WindowsMediaPlayer

    ();
    wmp.settings.autoStart = true;
    wmp.URL = @"http://media.jilion.com/videos/demo/midnight_sun_sv1_1_450p.mp4";
    FileDuration2 = wmp.currentMedia.durationString;
    Response.Write(FileDuration2);
    please help us..
  • #765315
    Hi,
    Try this:
    Double sz1 = axWindowsMediaPlayer1.Ctlcontrols.currentItem.duration;
    string sz2 = axWindowsMediaPlayer1.Ctlcontrols.currentItem.durationString;
    Double sz3 = axWindowsMediaPlayer1.currentMedia.duration;
    string sz4 = axWindowsMediaPlayer1.currentMedia.durationString;
    MessageBox.Show("1. " + sz1 + ", 2. " + sz2 + ", 3. " + sz3 + ", 4. " + sz4);
    Hope it helps.
    Regards,
    Shashikant Gurav
    shashikantgurav22@gmail.com

  • #765338
    I recommended to use given code snippet as guideline for how to apply WindowsMediaPlayer in C#
     axWindowsMediaPlayer1.currentPlaylist = axWindowsMediaPlayer1.mediaCollection.getByName("Yourmediafile");


    References
    http://www.c-sharpcorner.com/uploadfile/dpatra/using-windows-media-player-com-in-wpf/
    https://msdn.microsoft.com/en-us/library/windows/desktop/dd562851%28v=vs.85%29.aspx


Sign In to post your comments