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();
    }
4

1 回答 1

2

我认为你所追求的是

暂停:

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

开始

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

1:编辑
尝试这样的事情,现在我几乎给你你必须自己编写的代码。

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();
    }
于 2015-01-26T16:20:29.153 回答