I declare that this is what I saw on the Microsoft Forum. Many people are searching for C # mcisendstring () loop playing music.
Learning English is important.
Using System;
Using System. runtime. interopservices;
Using System. text;
Using System. Windows. forms;
Namespace Playmp3withwindow
{
Public Partial Class Form1: Form
{
Public Const Int Mm_mcinotify = 0x3b9 ; // This is the command to declare that the music mcisendstring () is sent to the System
[Dllimport ( " Winmm. dll " )]
Private Static Extern Long Mcisendstring ( String Command,
Stringbuilder returnstring,
Int Returnsize,
Intptr hwndcallback );
Public Form1 ()
{
Initializecomponent ();
Playsong (@"123.mp3");//When complete callback to defwndproc
//The path of the song. Play it at the beginning.
}
protected override void defwndproc ( ref message m)
{< br> base . defwndproc ( ref m );
If (M. MSG = mm_mcinotify) // determine whether the command is mm_mcinotify
// mcisendstring () mm_mcinotify command sent to the System
{< br> playsong ( @" 456.mp3 " ); // This is automatically played after broadcasting...
}< BR >}
Public Void Playsong ( String File)
{
Mcisendstring ( " Close Media " , Null , 0 , Intptr. Zero ); // Close
Mcisendstring ( " Open \" " + File + " \ "Type mpegvideo alias Media " , Null , 0 , Intptr. Zero );
// The song that opens the file path ", type mpegvideo is the file type, alias is to alias the file as media
Mcisendstring ( " Play media venture y " , Null , 0 , This . Handle ); // Play
}
}
}
SEO:Http://greatverve.cnblogs.com/archive/2011/06/24/mciSendString.html