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