运行项目c#音乐播放器时出错



嗨,这是一个简单的音乐播放器应用程序,我使用c#开发了一个YouTube视频,它就在最后,现在程序不会运行,因为它应该播放选定的音乐,你可以从附件的图片中看到错误是"错误CS0103名称'axWindowsMediaPlayer'不存在于当前上下文中">

不确定是否是编译错误

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 MusicPlayer
{
public partial class MusicPlayer : Form
{
public MusicPlayer()
{
InitializeComponent();
}
//Create Global variables of string type array to save the titles or name the of the songs and the path (location) of the songs 
string[] paths, files;
private void btnSelectSongs_Click(object sender, EventArgs e)
{
// code for selecting songs 
OpenFileDialog ofd = new OpenFileDialog();
// code for selecting multiple tracks 
ofd.Multiselect = true;
ofd.Filter = "All Supported Audio | *.mp3; *.wma | MP3s | *.mp3 | WMAs | *.wma";
if (ofd.ShowDialog()==System.Windows.Forms.DialogResult.OK)
{
files = ofd.SafeFileNames; // this is to save name of the songs in the files array
paths = ofd.FileNames; // this is to save the paths/location of the songs in the path array
// after that we display the music titles in the listbox
for (int i = 0; i <files.Length; i++)
{
listBoxSongs.Items.Add(files[i]); // this displays the songs in the list box
}
}
}
private void listBoxSongs_SelectedIndexChanged(object sender, EventArgs e)
{
// code for playing the sellected music 
axWindowsMediaPlayer.URL = paths[listBoxSongs.SelectedIndex];
}
private void pictureBox1_Click(object sender, EventArgs e)
{
// code for closing the app 
this.Close();
}
}
}

这是visual studio

中错误的样子

write click on media player>properties>name。检查玩家的名字,然后在你的代码中使用这个名字。

最新更新