歌曲长度//获取视频的长度
public int GetVideoLength(string SongPath)
{
string[] strs = new string[4];
//string SongPath = @"D:\蔡依林、陶喆 - 今天你要嫁给我 (吉特巴版).mp3";
string dirName = Path.GetDirectoryName(SongPath);
string SongName = Path.GetFileName(SongPath);//获得歌曲名称
FileInfo fInfo = new FileInfo(SongPath);
ShellClass sh = new ShellClass();
Folder dir = sh.NameSpace(dirName);
FolderItem item = dir.ParseName(SongName);
//string SongTime = Regex.Match(dir.GetDetailsOf(item, -1), "\\d:\\d{2}:\\d{2}").Value;//获取歌曲时间
string fileName = dir.GetDetailsOf(item, 0); //文件名
string fileSize = dir.GetDetailsOf(item, 1); //大小
string fileLength = dir.GetDetailsOf(item, 27); //时间
strs[0] = fileName; //文件名
strs[1] = dirName; //文件夹
strs[2] = fileSize; //大小
strs[3] = fileLength; //持续时间
return songLengthTo0Sec(strs[3]);
}
private int songLengthTo0Sec(string songLength)
{
string[] arr = songLength.Split(':');
int ret = Convert.ToInt32(arr[1]) * 60 + Convert.ToInt32(arr[2]);
return ret;
}
private string songLengthToMS(string songLength)
{
string[] arr = songLength.Split(':');
string ms = (Convert.ToInt16(arr[0]) * 3600000 + Convert.ToInt16(arr[1]) * 60000 + Convert.ToInt16(arr[2]) * 1000).ToString();
return ms;
}
private string songLengthTo0Min0Sec(string songLength)
{
string[] arr = songLength.Split(':');
string str = arr[1] + "分" + arr[2] + "秒";
return str;
}
private int songLengthTo0Sec(string songLength)
{
string[] arr = songLength.Split(':');
int ret = Convert.ToInt32(arr[1]) * 60 + Convert.ToInt32(arr[2]) ;
return ret;
}
private void button17_Click(object sender, EventArgs e)
{
//string cmd = "ffmpeg -ss 00:00:06 -i " + "\"D:\\input.mp4\"" + " -f image2 " + "\"D:\\test.jpg\"";
//string cmd = textBox10.Text;
//FFmpegExeCmd(cmd);
}
//获取歌曲的长度信息
public string[] GetSongInfo(string SongPath)
{
string[] strs = new string[4];
//string SongPath = @"D:\蔡依林、陶喆 - 今天你要嫁给我 (吉特巴版).mp3";
string dirName = Path.GetDirectoryName(SongPath);
string SongName = Path.GetFileName(SongPath);//获得歌曲名称
FileInfo fInfo = new FileInfo(SongPath);
ShellClass sh = new ShellClass();
Folder dir = sh.NameSpace(dirName);
FolderItem item = dir.ParseName(SongName);
//string SongTime = Regex.Match(dir.GetDetailsOf(item, -1), "\\d:\\d{2}:\\d{2}").Value;//获取歌曲时间
string fileName = dir.GetDetailsOf(item, 0); //文件名
string fileSize = dir.GetDetailsOf(item, 1); //大小
string fileLength = dir.GetDetailsOf(item, 27); //时间
strs[0] = fileName; //文件名
strs[1] = dirName; //文件夹
strs[2] = fileSize; //大小
strs[3] = fileLength; //持续时间
//for (int i = 0; i <= 80; i++)
//{
// Logrtb(dir.GetDetailsOf(item, i),richTextBox5);
//}
return strs;
}
文章评论 本文章有个评论