Question I can't control the video with the TrackBar1 scroller with Axvlc plugin c#

omar7625

Member
Joined
Feb 22, 2024
Messages
10
Programming Experience
1-3
I have tried axVLCPlugin21.input.time = trackBar1.Value; but to no avail

code.....

C#:
private void trackBar1_Scroll(object sender, EventArgs e)
{
    axVLCPlugin21.input.time = trackBar1.Value;
}

private void axVLCPlugin21_MediaPlayerTimeChanged(object sender, AxAXVLC.DVLCEvents_MediaPlayerTimeChangedEvent e)
{
    lb_START.Text = TimeFormat(e.time);
    trackBar1.Value = e.time;
}

private void axVLCPlugin21_MediaPlayerPlaying(object sender, EventArgs e)
{
    lb_END.Text = TimeFormat((int)axVLCPlugin21.input.length);
    trackBar1.Maximum = (int)axVLCPlugin21.input.length;
}
 
Last edited by a moderator:
That said, can you set the video position explicitly, without using a TrackBar? If not then the TrackBar is actually irrelevant to the issue.
Yes, I can set the video position without the TrackBar, but it's not accurate. When I try to advance the time by 90 seconds, it only advances 80 or 85 seconds, and sometimes time never advances.

This is a video explaining the problem...
 
I have tried axVLCPlugin21.input.time = trackBar1.Value; but to no avail

code.......

C#:
public Form1()
        {
            InitializeComponent();
        }
        private string TimeFormat(int iMilliseconds)
        {
            int iTotalsecond = iMilliseconds / 1000;
            int hours = iTotalsecond / 3600;
            int hours_res = iTotalsecond - (hours * 3600);
            int minutes = hours_res / 60;
            int minutes_res = hours_res - (minutes * 60);
            int seconds = minutes_res % 60;
            string strTimestring = String.Format("{0,1}:{1,2:D2}:{2,2:D2}", hours, minutes, seconds);
            return strTimestring;

        }

        private void trackBar1_Scroll(object sender, EventArgs e)
        {
            
          
            axVLCPlugin21.input.time = trackBar1.Value;
           // axVLCPlugin21.input.position = trackBar1.Value;
            
          


        }

        private void axVLCPlugin21_MediaPlayerTimeChanged(object sender, AxAXVLC.DVLCEvents_MediaPlayerTimeChangedEvent e)
        {
            lb_START.Text = TimeFormat(e.time);
            //axVLCPlugin21.input.time = e.time;
            trackBar1.Value = e.time;
        }

        private void axVLCPlugin21_MediaPlayerPlaying(object sender, EventArgs e)
        {
            lb_END.Text = TimeFormat((int)axVLCPlugin21.input.length);
            trackBar1.Maximum = (int)axVLCPlugin21.input.length;
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            axVLCPlugin21.playlist.add("https://cdn.flowplayer.com/a30bd6bc-f98b-47bc-abf5-97633d4faea0/hls/de3f6ca7-2db3-4689-8160-0f574a5996ad/playlist.m3u8");
            axVLCPlugin21.playlist.play();
        }

      
    }
}
 
You already have a thread about this open. Merging threads...
 
Yes, I can set the video position without the TrackBar

But you figured that showing us that code for comparison would be a bad idea?
 
We don't need or want the project file or the project as a whole. We want the code that is relevant to the problem. You say that you can get this to work by setting the field/property directly. Show us the code that does that, so we can compare it to the code you said doesn't work. If you'd like a solution to the problem, provide us with the information we need to solve it.
 
We don't need or want the project file or the project as a whole. We want the code that is relevant to the problem. You say that you can get this to work by setting the field/property directly. Show us the code that does that, so we can compare it to the code you said doesn't work. If you'd like a solution to the problem, provide us with the information we need to solve it.

This is the code that works axVLCPlugin21.input.time = 90000; But not perfectly , by the way. The number represents a fraction of a second.
 
With regards to post #5, that TimeFormat method is a waste of code. Just create a TimeSpan and call its ToString method:
C#:
var timeText = TimeSpan.FromMilliseconds(milliseconds).ToString("h\:mm\:ss");
You might want to double check but I think that format specifier is correct.
 
This is the code that works axVLCPlugin21.input.time = 90000; But not perfectly , by the way. The number represents a fraction of a second.

So, you're saying that if you use a literal value of 90000 it works - some of the time, at least - but if you use trackBar1.Value and it's equal to 90000 then it never works? I don't see how that's possible. There must be something else different.
 
So, you're saying that if you use a literal value of 90000 it works - some of the time, at least - but if you use trackBar1.Value and it's equal to 90000 then it never works? I don't see how that's possible. There must be something else different.

Yes, when I move TrackBar1.Value, time does not advance at all, as if something is running in the background to prevent time from responding to TrackBar1.Value.

This video explains the difference between using TrackBar.Value and button to specify a time value........ I hope to watch it
 
This video explains the difference between using TrackBar.Value and button to specify a time value........ I hope to watch it

You still haven't posted a link to the video. Neither in post #4 nor #13.
 

Latest posts

Back
Top Bottom