1.在工具箱里面添加控件Windows Media Player,默认初始工具箱是没有的
随便找个工具箱里面的空间右键-选择项
在com组件下选择
2.拖入面板Windows Media Player、button、textbox
3.代码
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 test5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
axWindowsMediaPlayer1.URL = this.textBox1.Text;
axWindowsMediaPlayer1.Ctlcontrols.play();
}
}
}