Use c # To play mp3

Source: Internet
Author: User

This class can directly play mp3 files

Usage:

ClsMCI cm = new clsMCI ();
Cm. FileName = "let alone I am a goat ";
Cm. play ();

 

 

Class Code





Using System;
Using System. Runtime. InteropServices;
Using System. Text;
Using System. IO;
Using System. Windows. Forms;
Namespace WindowsApplication7
{
/// <Summary>
/// Summary of clsMci.
/// </Summary>
Public class clsMCI
{
Public clsMCI ()
{
//
// TODO: add the constructor logic here
//
}

// Define the string variable used by the API Function
[Financialas (UnmanagedType. ByValTStr, SizeConst = 260)]
Private string Name = "";
[Financialas (UnmanagedType. ByValTStr, SizeConst = 128)]
Private string durLength = "";
[Financialas (UnmanagedType. LPTStr, SizeConst = 128)]
Private string TemStr = "";
Int ilong;
// Defines the enumerated variables of the playback status.
Public enum State
{
MPlaying = 1,
MPuase = 2,
MStop = 3
};
// Structure Variable
Public struct structMCI
{
Public bool bMut;
Public int iDur;
Public int iPos;
Public int iVol;
Public int iBal;
Public string iName;
Public State state;
};

Public structMCI mc = new structMCI ();

// Obtain the playback file attributes
Public string FileName
{
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.