C# Media Player (VLC or WMP) Doesn't Play - c#

I'm trying to build a simple media player. It has only Browse button, Play button and media player screen. I tried with Windows Media Player and VLC Media Player. In both codes below, Button1 is for browsing the video. Button2 is for playing. Browsing is working right but if I click Button2, nothing happens, and also I tried to see message if exists but it is not going to catch.
If I use Windows Media Player, I use this code;
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 videoplayerdeneme
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Button1_Click(object sender, EventArgs e)
{
OpenFileDialog opf = new OpenFileDialog();
if (opf.ShowDialog() == DialogResult.OK)
{
//textBox1.Text = opf.FileName;
axWindowsMediaPlayer1.URL = opf.FileName;
}
}
private void Button2_Click(object sender, EventArgs e)
{
try {
axWindowsMediaPlayer1.Ctlcontrols.play();
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
}
When I want to use VLC Media Player, I use this code;
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 videoplayerdeneme
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Button1_Click(object sender, EventArgs e)
{
OpenFileDialog opf = new OpenFileDialog();
if (opf.ShowDialog() == DialogResult.OK)
{
//textBox1.Text = opf.FileName;
axVLCPlugin21.playlist.add(opf.FileName, opf.SafeFileName, null);
}
}
private void Button2_Click(object sender, EventArgs e)
{
try {
axVLCPlugin21.playlist.play();
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
}
What am I missing in both cases? Please help me.
EDIT
I didn't add 64-bit VLC Media Player to Toolbox so I installed 32-bit version even my computer has 64-bit

Related

Autoplay video on windows form

i am new to .net i am having trouble playing videos automatically. I would be showing different textboxes here but i want the video to autplay without any buttons
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 WMPLib;
namespace ThinkQDisplay
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void axWindowsMediaPlayer1_Enter(object sender, EventArgs e)
{
AxWindowsMediaPlayer1.URL = "C:\Users\Ramrod\Documents\Visual Studio 2012\Projects\ThinkQDisplay\ThinkQDisplay\sample.avi";
}
}
}
It keeps telling it is an unrecognized escape sequence. Also I would like to have a separate form (form2). Where I can choose what to play here on form 1. Is it also possible to have it looped?
private void axWindowsMediaPlayer1_Enter(object sender, EventArgs e)
{
axWindowsMediaPlayer1.URL = #"C:\Users\Ramrod\Documents\Visual Studio 2012\Projects\ThinkQDisplay\ThinkQDisplay\sampler.avi";
}
private void Form1_Load(object sender, EventArgs e)
{
axWindowsMediaPlayer1.settings.autoStart = true;
}
}
}

Connecting VLC Plugin

I want to make stream application for RTSP cam to open VLC
when I press the button show to me the stream in the application but it doesn't show to me anything I want the program to display the stream in VLC
this the code of the application using c#
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 vlc
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void axVLCPlugin21_Enter(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
axVLCPlugin21.playlist.add("rtsp://192.168.0.209:554/mpeg4", "live", "network-caching=75");
//pictureBox1.Visible = false;
axVLCPlugin21.playlist.play();
}
}
}

C# Calling A Flash Variable From Another Form?

I am in need of a bit of help searched around the internet for about 2 days
to try and figure out how i can call an AxShockwaveFlash Variable from a second form this is for a game trainer something simple just getting into C# so i thought id start with one of these however i love everything i make to have a nice look and as many options as i can add so for my first C# Trainer i added a MenuStrip that opens a second form(VariableMods.cs) it has a few radio buttons a text box 3 toggle switches and 2 buttons one for setting a variable to whatever is typed in the text box while checking which radio button is checked and a button to close the variable menu which is another thing i need a bit of help with
-How do i Close the Second Form but still keep my Toggles On?
-How do i Call A Variable From (Form1.cs) to Form2(VariableMods.cs)
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 OCULAS
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//Show the Variable ModMenu
private void openVariableModsToolStripMenuItem_Click(object sender, EventArgs e)
{
VariableMods VarMenu = new VariableMods(this);
VarMenu.Show();
}
//Show About Program Box
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
InfoBox1 AboutBoxx = new InfoBox1();
AboutBoxx.Show();
}
//Close the Program
private void closeToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
That is my Form1 Code Have Not Put anything into it about the ShockwaveFlash yet
And
here is Form2(VariableMods)
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 OCULAS
{
public partial class VariableMods : Form
{
Form1 originalForm; //Using "OriginalForm" To Call "Form1"
public VariableMods(Form1 IncomingForm)
{
originalForm = IncomingForm; //originalForm(Form1) is the form to be called
InitializeComponent();
BoxHeadVariables utf = new BoxHeadVariables();
}
private void ambiance_Button_21_Click(object sender, EventArgs e)
{
this.Hide();
}
private void ambiance_Button_11_Click(Form1 incomingForm, object sender, EventArgs e)
{
if (ambiance_RadioButton1.Checked == true)
{
MessageBox.Show("Damage Mod Is Active");
}
if (ambiance_RadioButton2.Checked == true)
{
MessageBox.Show("Speed Mod Is Active");
}
if (ambiance_RadioButton3.Checked == true)
{
MessageBox.Show("Range Mod Is Active");
}
}
}
}

Emgu System.TypeInitializationException on 32 bit windows 7 OS

I am working On Emgu cv on windows 7 32 bit os and, System.TypeInitializationException Error occurs, i tried every solution;
When i run the Examples coming with Emgu it's Ok but when i create my own project the error occurs.
here is my code;
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 Emgu.CV;
using Emgu.CV.Structure;
using Emgu.Util;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private Capture cap;
private bool capinpro;
public Form1()
{
InitializeComponent();
}
private void processframe(object o, EventArgs e)
{
Image<Bgr, byte> img = cap.QueryFrame();
imageBox1.Image = img;
}
private void button1_Click(object sender, EventArgs e)
{
if(cap!=null)
{
try
{
if (capinpro)
{
Application.Idle += processframe;
//i have also tried cap.start();
}
else
{
Application.Idle -= processframe;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
else
{
cap= new Capure();
}
}
}
}
Emgu library was requiring more dll Files, so I pasted all the dlls from the bin folder of Emgu to the path of my EXE file and the problem was solved.

visual c# 2010 playing sound in form 1 (From resorce file)

OK i am trying to make my form 1 application play a .wav file i have imported to my resource file i have serched for this online but all i can find is
Sub PlayBackgroundSoundFile()
My.Computer.Audio.Play("C:\Waterfall.wav", _
AudioPlayMode.Background) End Sub
but i believe this is for a console application if not not matter where i put the code i get an lots of errors
Here is the code i am working with:
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 System.Media;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void pictureBox1_Click(object sender, EventArgs e)
{
var myForm = new Form1();
myForm.Show();
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
}
private class form1_load
{
}
}
}
What do i have to add and where bare in mind i have never used any method like this before
if you with to just edit the code the name of the file is sound.wav
I just did it myself: created simple form with one button and created event to this button. Contents of Form1 class is:
using System;
using System.Media;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btPlay_Click(object sender, EventArgs e)
{
string path;
using (var dlg = new OpenFileDialog())
{
dlg.Multiselect = false;
dlg.Filter = "WAV files|*.wav";
if (dlg.ShowDialog() == DialogResult.Cancel) return;
path = dlg.FileName;
}
SoundPlayer sp = new SoundPlayer(path);
sp.Play();
}
}
}
And it works perfectly. Try this on, an if you're still gonna be having errors, you could post here which errors exactly. It would help me in helping you.

Categories

Resources