The specific source code is as follows:
This article refers to the address: http://
First, use the API function mciSendString to form a media player class.
Using System;
Using System.Runtime.InteropServices;
Using System.Text;
Using System.IO ;
Namespace clsMCIPlay
{
///
/// A summary description of clsMci.
///
Public class clsMCI
{
Public clsMCI()
{
//
// TODO: Add constructor logic here
//
}
/ / Define the string variable used by the API function
[MarshalAs (Unmana
Private string Name = "" ;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=128)]
Private string durLength = "" ;
[MarshalAs(UnmanagedType.LPTStr, SizeConst=128)]
Private string TemStr ="";
Int ilong;
/ / Define the playback state enumeration variable
Public enum State
{
mPlaying = 1,
mPuase = 2,
mStop = 3
};
/ / Structural variables
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() ;
/ / Get the play file properties
Public string FileName
{
Get
{
Return mc.iName;
}
Set
{
//ASCIIEncoding asc = new ASCIIEncoding();
Try
{
TemStr ="";
TemStr = TemStr.PadLeft(127, Convert.ToChar(" "));
Name = Name.PadLeft(260, Convert.ToChar(" ")) ;
mc.iName = value;
Ilong = APIClass.GetShortPathName(mc.iName,Name, Name.Length);
Name = GetCurrPath(Name);
//Name = "open " + Convert.ToChar(34) + Name + Convert.ToChar(34) + " alias media";
Name = "open " + Convert.ToChar(34) + Name + Convert.ToChar(34) + " alias media";
Ilong = APIClass.mciSendString("close all", TemStr, TemStr.Length, 0);
Ilong = APIClass.mciSendString( Name, TemStr, TemStr.Length, 0);
Ilong = APIClass.mciSendString("set media time format milliseconds", TemStr, TemStr.Length , 0);
Mc.state = State.mStop;
}
Catch
{
MessageBox.Show("Error error!");
}
}
}
//play
Public void play()
{
TemStr = "";
TemStr = TemStr.PadLeft(127, Convert.ToChar(" "));
APIClass.mciSendString("play media", TemStr, TemStr.Length, 0);
Mc.state = State.mPlaying ;
}
//stop
Public void StopT()
{
TemStr = "";
TemStr = TemStr.PadLeft(128, Convert.ToChar(" "));
Ilong = APIClass.mciSendString("close media", TemStr, 128, 0);
Ilong = APIClass.mciSendString("close all", TemStr, 128, 0);
Mc.state = State.mStop ;
}
Public void Puase()
{
TemStr = "";
TemS
Ilong = APIClass.mciSendString("pause media", TemStr, TemStr.Length, 0);
Mc.state = State.mPuase ;
}
Private string GetCurrPath(string name)
{
If(name.Length <1) return "";
Name = name.Trim();
Name = name.Substring(0,name.Length-1);
Return name;
}
//total time
Public int Duration
{
Get
{
durLength = "";
durLength = durLength.PadLeft(128, Convert.ToChar(" ")) ;
APIClass.mciSendString("status media length", durLength, durLength.Length, 0);
durLength = durLength.Trim();
If(durLength == "") return 0;
Return (int)(Convert.ToDouble(durLength) / 1000f);
}
}
//current time
Public int CurrentPosition
{
Get
{
durLength = "";
durLength = durLength.PadLeft(128, Convert.ToChar(" ")) ;
APIClass.mciSendString("status media position", durLength, durLength.Length, 0);
mc.iPos = (int)(Convert.ToDouble(durLength) / 1000f);
Return mc.iPos;
}
}
}
Public class APIClass
{
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
Public static extern int GetShortPathName (
String lpszLongPath,
String shortFile,
Int cchBuffer
);
[DllImport("winmm.dll", EntryPoint="mciSendString", CharSet = CharSet.Auto)]
Public static extern int mciSendString (
String lpstrCommand,
String lpstrReturnString,
Int uReturnLength,
Int hwndCallback
);
}
}
PV solar module has high power. with high density interconnect technology. Multi-busbar technology for better light trapping effect. lower series resistance and improved current collection. High Efficiency Solar Panels, Silicon Pv Module, Solar Pv Module Ul, 144 Solar Cells Mono Solar Panel Efficient for global market.
High Efficiency Solar Panels,Silicon Pv Module,Solar Pv Module Ul,Mono Solar Panel Efficient
Jiangxi Huayang New Energy Co.,Ltd , https://www.huayangenergy.com