سؤال

I'm using a simple open file dialogue to open a video file and play it via VLC. All works great, but I can NOT get the volume to mute for the life of me.

    System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
    ofd.ShowDialog();
    if (ofd.FileName != "")
    {

       vlc.addTarget("file:///" + ofd.FileName, null,AXVLC.VLCPlaylistMode.VLCPlayListReplaceAndGo, 0);

       vlc.play();
       vlc.AutoLoop = true;
       vlc.Volume = 0;
       vlc.toggleMute();


}

I have tried setting volume to 0 and there toggleMute function with no luck. I have also tried doing the mute functionality in the playEvent, with no luck. Could anyone shine some light on the situation?

EDIT: So, I tossed in a System.Threading.Thread.Sleep(1000); before my call to adjust the volume and mute. To my surprise, the volume is muted after a one second delay. Does anyone have a "real" fix for this as it seems like it could cause issues / not work correctly on slower machines

هل كانت مفيدة؟

المحلول

This issue occurse since VLC 2.0.9. VLC version 2.0.8 doenst need an delay. All versions >2.0.8 need delays... Solution is use version 2.0.8 and it works fine.

نصائح أخرى

/// <summary>
/// Play a filename
/// </summary>
/// <param name="fileName">filename</param>
public void Play(string fileName)
{
    this.VlcControl.Media = new Vlc.DotNet.Core.Medias.PathMedia(fileName);
    Task.Factory.StartNew(this.Mute);
}

/// <summary>
/// Mute audio
/// </summary>
private void Mute()
{            
    this.VlcControl.AudioProperties.IsMute = true;
    if (!this.VlcControl.AudioProperties.IsMute)
    {
        // Retry mute
        Task.Factory.StartNew(this.Mute);
    }
 }
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top