• Advertisement
Sign in to follow this  

c# beginneer programmer

Recommended Posts

Help me! 

I am trying to pass a video between forms. 

i created 2 forms and i added button1,button2, listbox1, openfiledialog1 in first form and then i added just a media player in second form. I press button1 and select video then press button2 and the video opens in form2 but i can't do this :( :( 

This is Form1

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace lord
{
    public partial class Form1 : Form
    {
       
     
        public Form1()
        {
            InitializeComponent();
        }

        public void button1_Click(object sender, EventArgs e)
        {
            openFileDialog1.ShowDialog();

            OpenFileDialog filedialog = new OpenFileDialog();
            
            if (filedialog.ShowDialog() == DialogResult.OK)
                
            {
                
                FileInfo dosyabilgisi = new FileInfo(filedialog.FileName);

               listBox1.Items.Add("" + dosyabilgisi.Name);

            }
            

        }

        public void openFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
            axWindowsMediaPlayer1.URL = openFileDialog1.FileName;
        
        
                }

        public void Form1_Load(object sender, EventArgs e)
        {
            axWindowsMediaPlayer1.settings.autoStart = false;

        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            axWindowsMediaPlayer1.Ctlcontrols.play();
           
        }
    }
}

 And this is form2

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace lord
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {
           
        }
    }
}

Form2 is empty :) Show me the way out.

Share this post


Link to post
Share on other sites
Advertisement

maybe you should set the visibility of video player on the second form to "public"

then in form 1 after clicking button2 you should write:

Form2 frm2 = new Form2();


frm2.videoPlayer1.video = some video; // i don't know which component you are using but in here set the video on the second form

// and if you wanted form 2 to be loaded as a dialog :

if(frm2.ShowDialog() == DialogResult.Ok){
 // do somthing
}

I guess this was the answer? or something else you desired?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Advertisement