Note that there are some explanatory texts on larger screens.

plurals
  1. POplaying video file using form application in c# with DirectX and not with Windows media player
    text
    copied!<p>i want to play video in c#. i searched related tutorial and i found <a href="http://www.dreamincode.net/forums/topic/111181-adding-video-to-an-application/" rel="nofollow noreferrer">this</a>. i followed exactly the same but the video would not appear.</p> <p>here is my code.</p> <pre><code> using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Microsoft.DirectX.AudioVideoPlayback; namespace WindowsFormsApplication4 { public partial class Form1 : Form { Video video; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == DialogResult.OK) { // store the original size of the panel int width = panel1.Width; int height = panel1.Height; // load the selected video file //video = new Video("C:\\Users\\HDAdmin\\Desktop\\Example.avi"); video = new Video(openFileDialog1.FileName); // set the panel as the video object’s owner video.Owner = panel1; // stop the video video.Stop(); // resize the video to the size original size of the panel panel1.Size = new Size(width, height); try { video.Audio.Volume = 100; } catch { } } } private void button2_Click(object sender, EventArgs e) { if (video.State != StateFlags.Running) { video.Play(); } } private void button3_Click(object sender, EventArgs e) { if (video.State == StateFlags.Running) { video.Pause(); } } private void button4_Click(object sender, EventArgs e) { if (video.State != StateFlags.Stopped) { video.Stop(); } } } } </code></pre> <p>i even tried to put a path of the video like this: </p> <pre><code>video = new Video("C:\\Users\\HDAdmin\\Desktop\\Example.avi"); </code></pre> <p>but both of it will show the error like picture below. <img src="https://i.stack.imgur.com/aKVdR.png" alt="enter image description here"></p> <p>my question is, how i want to enable to view and play the video by using windows form application in c#?</p> <p>p/s: i want to use Directx only and do not want to play the video in windows media player.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload