Play Sound



#pragma once

namespace My48 {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
///
/// Summary for Form1
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
///

public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
///
/// Clean up any resources being used.
///

~Form1()
{
if (components)
{
delete components;
}
}
private: AxWMPLib::AxWindowsMediaPlayer^ w;
protected:
private: System::Windows::Forms::Button^ BtnPlay;
private:
///
/// Required designer variable.
///

System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
this->w = (gcnew AxWMPLib::AxWindowsMediaPlayer());
this->BtnPlay = (gcnew System::Windows::Forms::Button());
(cli::safe_cast
(this->w))->BeginInit();
this->SuspendLayout();
//
// w
//
this->w->Enabled = true;
this->w->Location = System::Drawing::Point(11, 13);
this->w->Name = L"w";
this->w->OcxState = (cli::safe_cast
(resources->GetObject(L"w.OcxState")));
this->w->Size = System::Drawing::Size(269, 184);
this->w->TabIndex = 0;
//
// BtnPlay
//
this->BtnPlay->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast
(222)));
this->BtnPlay->Location = System::Drawing::Point(12, 211);
this->BtnPlay->Name = L"BtnPlay";
this->BtnPlay->Size = System::Drawing::Size(267, 45);
this->BtnPlay->TabIndex = 1;
this->BtnPlay->Text = L"Play";
this->BtnPlay->UseVisualStyleBackColor = true;
this->BtnPlay->Click += gcnew System::EventHandler(this, &Form1::BtnPlay_Click);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(292, 266);
this->Controls->Add(this->BtnPlay);
this->Controls->Add(this->w);
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
(cli::safe_cast
(this->w))->EndInit();
this->ResumeLayout(false);
}
#pragma endregion
//Play Sound
private: System::Void BtnPlay_Click(System::Object^ sender, System::EventArgs^ e) {
w->URL="D:\\Song\\01 Track 1.mp3";
w->Ctlcontrols->play();
}
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
this->Text="Play Sound";
this->BackColor=Color::Yellow;
this->MaximizeBox=false;
BtnPlay->BackColor=Color::Black;
BtnPlay->ForeColor=Color::White;
}
};
}