Vlc.DotNet icon indicating copy to clipboard operation
Vlc.DotNet copied to clipboard

Why does the trackbar stop working on my videos in my c# application?

Open VijayRed01 opened this issue 3 years ago • 6 comments

I have an issue / a question (pick one) about Vlc.DotNet.

Generic information

  • Vlc.DotNet version : (3.1.0)
  • Vlc.DotNet project used : (WinForms)
  • libvlc version : (Please fill) (x86/x64) + how did you get it?
  • .net version : (4.8.03752)
  • Project language : (C#)
  • Project build architecture : (AnyCPU )
  • Operating system : (Windows x64)

Summary

I am creating an application using vlc.dotnet, I wanted to implement a trackbar to be able to scroll through the video. However the problem I am facing is that, the trackbar seems to be able to work until a specific point in the video and this seems to be different with each video. Below is a summary of my code, as the actual code is really long.


Decimal value;
 decimal value2;
 
 private void Form1_Load(object sender, EventArgs e)
        {
        
          trackBar1.ValueChanged += new EventHandler(trackBar1_ValueChanged);
          
           control = new VlcControl();
            var currentAssembly = Assembly.GetEntryAssembly();
            var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName;
            var libDirectory = new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64"));
            control.BeginInit();
            control.VlcLibDirectory = libDirectory;
            control.Dock = DockStyle.Fill;
            control.EndInit();
            panel1.Controls.Add(control);
            
             main_form_LC4_data();
        }
        
         void main_form_LC4_data()
        {
           control.SetMedia(new Uri(selected_LC4_File).AbsoluteUri);
                control.Audio.Volume = 0;
                control.Update();
        }
        
          private void button11_Click(object sender, EventArgs e)
        {
             trackBar1.Value += (int)value2;
        }
        
        private void button12_Click(object sender, EventArgs e)
        {
                if (trackBar1.Value == 0)
            {

            }
            else
            {
                trackBar1.Value -= (int)value2;
            }
        }
        
         private void trackBar1_ValueChanged(object sender, System.EventArgs e)
        {
           control.Time = trackBar1.Value;
          
        }

The code also has two buttons which increments and decrement the value within the trackbar, so the user is able to use that alongside the trackbar to scroll through the video. These buttons also work to a certain point and then stop. The video contains lines of Meta data which is linked to each frame, so using the length of the video and the number of lines of meta data, I tried to calculate the max length and the tick frequency and that didn’t seem to work either. Below is the code to show how I tried to implement the calculations.

  var player = new WindowsMediaPlayer();
        var clip = player.newMedia(selected_LC4_File);
        string vOut = clip.duration.ToString();

        long howdy = Convert.ToInt64(clip.duration); 

        string vOut2 = vOut.Replace(".", "");
        int x = Int32.Parse(vOut2);
        int x_result = x * 10;
        int test = lc4_file_calculations.Count;
        value = Decimal.Divide(x_result, test);
        
        Console.WriteLine("Video Time : " + x_result);
        Console.WriteLine("Frames : " + test);
        Console.WriteLine("FPS : " + value);
        
         value2 = value;
        
         int a = test;
        trackBar1.Maximum = a
        trackBar1.TickFrequency = value;
  • [ ] I confirm that my issue doesn't happen in VLC itself.

VijayRed01 avatar Oct 20 '20 12:10 VijayRed01

Please:

  1. Try the same video files with VLC
  2. If it does work, please send verbose logs (-vv)

jeremyVignelles avatar Oct 20 '20 13:10 jeremyVignelles

Please:

1. Try the same video files with VLC

2. If it does work, please send verbose logs (`-vv`)

Hi

  1. do you mean the actual VLC player it does work with that

  2. i am unaware in how to send those, honeslty not sure what that is

if it helps this as an example one video i have says the length of it is 8.36 which times by 1000 = 8360 which is what i used to set the maximum on the track bar and the trackbar and buttons worked till 7524 after that the values do go up and down once they go below 7524 it all works again however anything after that time index the screen (panel1) doesnt update and is frozen at that time index

also unaware if the answer to the problem is the same as this one, just thought i would ask. i have added a play button and pause button. once my video reaches the end of the video, everything including the tracbar and skip button stop working, again it is as if it is frozen

VijayRed01 avatar Oct 20 '20 13:10 VijayRed01

  1. Yes I meant the real VLC application, with the same version as the one you're using from Vlc.DotNet. Most issues with the seekbar not updating is caused by the core, and depend on the media being played rather than Vlc.DotNet. It could also be your code that is problematic, and we can't say if we don't have a proper way to reproduce the issue (full minimal code, hosted on a github repo, with the media you're trying to play)

  2. https://github.com/ZeBobo5/Vlc.DotNet/wiki/Getting-started#how-to-debug

jeremyVignelles avatar Oct 20 '20 14:10 jeremyVignelles

1. Yes I meant the real VLC application, with the same version as the one you're using from Vlc.DotNet.
   Most issues with the seekbar not updating is caused by the core, and depend on the media being played rather than Vlc.DotNet. It could also be your code that is problematic, and we can't say if we don't have a proper way to reproduce the issue (full minimal code, hosted on a github repo, with the media you're trying to play)

2. https://github.com/ZeBobo5/Vlc.DotNet/wiki/Getting-started#how-to-debug

Hi i have uploaded a simple version of my code which shows the error, i have written a readme section which shows you how to use the application once it has started, it also out lines the issue i am facing as well

https://github.com/VijayRed01/TS1_C

Thank you

VijayRed01 avatar Oct 20 '20 18:10 VijayRed01

Use

private void trackBar1_ValueChanged(object sender, EventArgs e)
{
    control.Time = trackBar1.Value; //correct
}

Instead of invoking and updating etc.

private void trackBar1_ValueChanged(object sender, EventArgs e)
{
    Time_update(trackBar1.Value); //wrong
}

graysuit avatar Oct 28 '20 16:10 graysuit

Use

private void trackBar1_ValueChanged(object sender, EventArgs e)
{
    control.Time = trackBar1.Value; //correct
}

Instead of invoking and updating etc.

private void trackBar1_ValueChanged(object sender, EventArgs e)
{
    Time_update(trackBar1.Value); //wrong
}

Hi

i have tried that however the video just hangs after a while

i did try control.Play(); System.Threading.Thread.Sleep(40); control.Pause(); control.Time = trackBar1.Value;

And that sort of works however causes a lot more issues

VijayRed01 avatar Nov 24 '20 11:11 VijayRed01