Ok I got the newest solution:
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 MediaPlayer
{
public partial class Form1 : Form
{
Timer t;
public Form1()
{
InitializeComponent();
axWindowsMediaPlayer1.uiMode = "none";
t = new Timer();
t.Interval = 1000;
t.Tick += new EventHandler (t_Tick);
}
void t_Tick(object sender, EventArgs e)
{
trackBar1.Value = (int)axWindowsMediaPlayer1.Ctlcontrols.currentPosition;
label1.Text = axWindowsMediaPlayer1.Ctlcontrols.currentPosition.ToString();
}
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.ShowDialog();
if(dlg.FileName != null)
{
axWindowsMediaPlayer1.URL = dlg.FileName;
}
}
private void button2_Click(object sender, EventArgs e)
{
axWindowsMediaPlayer1.Ctlcontrols.play();
t.Start();
}
private void button3_Click(object sender, EventArgs e)
{
axWindowsMediaPlayer1.Ctlcontrols.pause();
t.Stop();
}
private void axWindowsMediaPlayer1_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
{
if(axWindowsMediaPlayer1.currentMedia != null)
{
trackBar1.Maximum = (int)Math.Round(axWindowsMediaPlayer1.currentMedia.duration);
t.Start();
}
}
private void trackBar1_Scroll(object sender, EventArgs e)
{
axWindowsMediaPlayer1.Ctlcontrols.currentPosition = trackBar1.Value;
}
}
}