开发者

Start process in child form from parent form failed

I'm developing an application with two forms. The parent form contains a list of (video) file names and in the other form (child) i start a proces (using mplayer) to show the corresponding video.

My goal is to start the video in the child form after clicking on the file name (listview) in my main (parent) form. The video form must be a 'floating window'. So not embedded in the main form as MDI form!!

When i start the player in the video form (child) directly, everything works fine (the file name is available from the main form) and the video is shown in the video form. (start button calls method OpenFile())

When i try to start the video from the main form the video starts, but not shown in the video form (i can hear the music)

frmVideo formVideo = new frmVideo();
formVideo.OpenFile();

I am assuming that something goes wrong with the handle between the main form and the video form.

public void OpenFile()
    {
        //
        try
        {
            ps = new Process();

            //Path of Mplayer exe
            ps.StartInfo.FileName = @"C:\Program Files\SMPlayer\mplayer\mplayer.exe";

            ps.StartInfo.UseShellExecute = false;
            ps.StartInfo.CreateNoWindow = true;

            ps.StartInfo.RedirectStandardInput = true;
            args = "-nofs -noquiet -identify -slave ";
            args += "-nomouseinput -sub-fuzziness 1 ";

            //-wid will tell MPlayer to show output inisde our panel
            args += " -vo direct3d, -ao dsound  -wid ";
            int id = (int)panel1.Handle;
            args += id;

            //
            string filename = Form1.videoFile;  //file name from my main form

        开发者_开发知识库    // start player,
            ps.StartInfo.Arguments = args + " \"" + filename + "\"";
            ps.Start();

      }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜