how to use video files in c#???in which format we can use video files in c#???which control we can use for video files in c#???

Recommended Answers

1)Add Panel in which video will be displayed...background color of panel is black

In second Panel (background color of panel is black)
2)Add Button to browse the path of a vedio file
3)Add Button to Play
4)Add Button to Pause
5)Track Bar
6)Add status strip below the second panel

Jump to Post

All 2 Replies

1)Add Panel in which video will be displayed...background color of panel is black

In second Panel (background color of panel is black)
2)Add Button to browse the path of a vedio file
3)Add Button to Play
4)Add Button to Pause
5)Track Bar
6)Add status strip below the second panel

namespace Play_Video
{

    public partial class Form1 : Form
    {
     

       Video vdo;
      
        public string mode="play";
        public string PlayingPosition, Duration;
        public Form1()
        {
            InitializeComponent();
            VolumeTrackBar.Value = 4;
        }

      

        private void timer1_Tick(object sender, EventArgs e)
        {
           
            PlayingPosition = CalculateTime(vdo.CurrentPosition);
            txtStatus.Text = PlayingPosition + "/" + Duration;
            
            if (vdo.CurrentPosition == vdo.Duration)
            {
                timer1.Stop();
                Duration = CalculateTime(vdo.Duration);
                PlayingPosition = "0:00:00";
                txtStatus.Text = PlayingPosition + "/" + Duration;
                vdo.Stop();
                btnPlay.BackgroundImage = Play_Video.Properties.Resources.btnplay;
                vdoTrackBar.Value = 0;
            }
            else
                vdoTrackBar.Value += 1;
         
        }
        
        private void btnupload_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.ShowDialog();
            openFileDialog1.Title = "Select video file..";
            openFileDialog1.InitialDirectory = Application.StartupPath;
            openFileDialog1.DefaultExt = ".avi";
            openFileDialog.Filter = "Media Files|*.mpg;*.avi;*.wma;*.mov;*.wav;*.mp2;*.mp3|All Files|*.*";
            vdo = new Video(openFileDialog.FileName);
            
            vdo.Owner = panel1;
            panel1.Width = 700;
            panel1.Height = 390;
            Duration = CalculateTime(vdo.Duration);
            PlayingPosition = "0:00:00";
            txtStatus.Text = PlayingPosition + "/" + Duration;
           
            vdoTrackBar.Minimum = 0;
            vdoTrackBar.Maximum = Convert.ToInt32(vdo.Duration);
           
        }

        private void btnPlay_Click(object sender, EventArgs e)
        {

            if (vdo != null)
            {
                if (vdo.Playing)
                {
                    vdo.Pause();
                    timer1.Stop();
                    btnPlay.BackgroundImage = Play_Video.Properties.Resources.btnplay;
                }
                else
                {
                    vdo.Play();
                    timer1.Start();

                    btnPlay.BackgroundImage = Play_Video.Properties.Resources.pause;
                }
            }
                       
        }
       
        private void btnStop_Click(object sender, EventArgs e)
        {
            vdo.Stop();
            btnPlay.BackgroundImage = Play_Video.Properties.Resources.btnplay;
            vdoTrackBar.Value = 0;
        }

        public string CalculateTime(double Time)
        {
            string mm, ss, CalculatedTime;
            int h, m, s, T;

            Time = Math.Round(Time);
            T = Convert.ToInt32(Time);

            h = (T / 3600);
            T = T % 3600;
            m = (T / 60);
            s = T % 60;

            if (m < 10)
                mm = string.Format("0{0}", m);
            else
                mm = m.ToString();
            if (s < 10)
                ss = string.Format("0{0}", s);
            else
                ss = s.ToString();

            CalculatedTime = string.Format("{0}:{1}:{2}", h, mm, ss);

            return CalculatedTime;
        }
  private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
            Duration = CalculateTime(vdo.Duration);
            PlayingPosition = "0:00:00";
            txtStatus.Text = PlayingPosition + "/" + Duration;
        }

        private void vdoTrackBar_Scroll(object sender, EventArgs e)
        {
            if (vdo != null)
            {
                vdo.CurrentPosition = vdoTrackBar.Value;
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            MaximizeBox = false;


        }

    }
}

Hope this is what you were looking for .....

how to use video files in c#???in which format we can use video files in c#???which control we can use for video files in c#???

first add this two dll library:
1)Axinterop.shockwaveflashobjects.dll
2)interop.shockwaveflashobjects.dll

now place control Axshockwaveflash on your form and in form's load event write

Axshockwaveflash.movie="url";

if it is .FLV then first convert it into .MP4 and then convert it into .SWF...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.