0

I am developing an app. in windows form application in C# , which user can upload two video in two separate player and there are Play, Pause, and Stop button which enables the user to play,pause and stop two video synchronously.

For the Pause function, when the user presses the button it stops at that time spot but when the play button is pressed it starts from the begining of the stream.

For that, I want to save the time of the first and second videos in which the pause button was chosen and save them to a text-file for example: first line- first player: 01:02:03 , and second line-second player: 04:05:03 and then when the play button is set it reads from the text file and start from those given times of each player.

I have clearly in my mind what to do, but need some help for writing the code.

Thank you

    private void Play_button2_Click(object sender, EventArgs e)
    {
        axWindowsMediaPlayer1.URL = Path_textBox1.Text;
        axWindowsMediaPlayer1.Ctlcontrols.play();

        axWindowsMediaPlayer2.URL = Path_textBox2.Text;
        axWindowsMediaPlayer2.Ctlcontrols.play();
    }

    private void Stop_button3_Click(object sender, EventArgs e)
    {
        axWindowsMediaPlayer1.Ctlcontrols.stop();
        axWindowsMediaPlayer2.Ctlcontrols.stop();
    }

    private void Pause_button1_Click_1(object sender, EventArgs e)
    {
        axWindowsMediaPlayer1.Ctlcontrols.pause();

        axWindowsMediaPlayer2.Ctlcontrols.pause();
    }
Arian
  • 73
  • 12
  • why need to write to a file? Just create two instance-members of type DateTime (one for each player) and set its time appropriatly. Btw.: how can the times from the players differ? If you press play both should start, should´nt they? Thus they should always have same time. – MakePeaceGreatAgain Jan 26 '15 at 16:06
  • Why do you need to write it to a file? Couldn't it all be in memory? – Jonesopolis Jan 26 '15 at 16:06
  • What isn't working with your code currently? The pause/play methods sound like they would already do what you want them to – Sayse Jan 26 '15 at 16:07
  • 1
    I think you want to set the URL once? Setting the URL in the handler might be resetting the stream. – Lews Therin Jan 26 '15 at 16:12
  • 1
    @HimBromBeere it is also possible to play/pause the players from the WMPs separately; I want to play them synchronously as well so I added those extra buttons! – Arian Jan 26 '15 at 16:19
  • @Jonesy ,I have no Idea, how can I figure out if the pause- time for both are saved in memory and how can I access them? – Arian Jan 26 '15 at 16:22

1 Answers1

2

I think that what you are after is something like

for pause:

double currentposition1 = player1.Ctlcontrols.currentPosition();
double currentposition2 = player2.Ctlcontrols.currentPosition();

for start

player1.Ctlcontrols.currentPosition = currentposition1;
player2.Ctlcontrols.currentPosition = currentposition2;

1:EDIT
try something like this, now I'm almost giving you the code that you have to write yourself.

private double currentposition1;
private double currentposition2;
private void Play_button2_Click(object sender, EventArgs e)
    {
        if(currentposition1!=0)
        {
           player1.Ctlcontrols.currentPosition = currentposition1;
           player2.Ctlcontrols.currentPosition = currentposition2;
        }
        axWindowsMediaPlayer1.URL = Path_textBox1.Text;
        axWindowsMediaPlayer1.Ctlcontrols.play();

        axWindowsMediaPlayer2.URL = Path_textBox2.Text;
        axWindowsMediaPlayer2.Ctlcontrols.play();
    }

    private void Stop_button3_Click(object sender, EventArgs e)
    {
        axWindowsMediaPlayer1.Ctlcontrols.stop();
        axWindowsMediaPlayer2.Ctlcontrols.stop();
    }

    private void Pause_button1_Click_1(object sender, EventArgs e)
    {
        currentposition1 = player1.Ctlcontrols.currentPosition();
        currentposition2 = player2.Ctlcontrols.currentPosition();
        axWindowsMediaPlayer1.Ctlcontrols.pause();
        axWindowsMediaPlayer2.Ctlcontrols.pause();
    }
Narzul
  • 113
  • 8