关于得到歌曲总时间
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Microsoft.Win32;
using System.Runtime.InteropServices;
namespace _0
{
public partial class Form1 : Form
{// API 宣告
[DllImport("winmm.dll", EntryPoint = "mciSendString", CharSet = CharSet.Auto)]
public static extern int mciSendString(
string lpstrCommand, string lpstrReturnString,
int uReturnLength, int hwndCallback);
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object s, EventArgs e)
{
MessageBox.Show(GetMediaLen(@"E:\MP3\bjbl.mp3").ToString() + " Sec");
}
// 取得多媒體檔案長度
private long GetMediaLen(string File)
{
long RetVal = 0;
string key = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\MCI Extensions";
RegistryKey RegKey = Registry.LocalMachine.OpenSubKey(key);
if (RegKey == null)
RegKey = Registry.LocalMachine.CreateSubKey(key);
string FileExt = Path.GetExtension(File).Replace(".", "");
string tp = RegKey.GetValue(FileExt, "MPEGVideo").ToString();
RegKey.Close();
string tm = new string((char)0, 128);
if (mciSendString("open \"" + File + "\" type " + tp + " alias Media", null, 0, 0) == 0)
{
if (mciSendString("status Media length", tm, tm.Length, 0) == 0)
{
tm = tm.Trim((char)0);
if (!string.IsNullOrEmpty(tm)) RetVal = Convert.ToInt64(tm) / 1000;
}
mciSendString("close Media", null, 0, 0);
}
return RetVal;
}
}
}
//大家好,上面的代码运行时没有提示错误,为什么得到的时间是0秒;麻烦大家一下,怎样修改才能得到歌曲的总时间;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Microsoft.Win32;
using System.Runtime.InteropServices;
namespace _0
{
public partial class Form1 : Form
{// API 宣告
[DllImport("winmm.dll", EntryPoint = "mciSendString", CharSet = CharSet.Auto)]
public static extern int mciSendString(
string lpstrCommand, string lpstrReturnString,
int uReturnLength, int hwndCallback);
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object s, EventArgs e)
{
MessageBox.Show(GetMediaLen(@"E:\MP3\bjbl.mp3").ToString() + " Sec");
}
// 取得多媒體檔案長度
private long GetMediaLen(string File)
{
long RetVal = 0;
string key = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\MCI Extensions";
RegistryKey RegKey = Registry.LocalMachine.OpenSubKey(key);
if (RegKey == null)
RegKey = Registry.LocalMachine.CreateSubKey(key);
string FileExt = Path.GetExtension(File).Replace(".", "");
string tp = RegKey.GetValue(FileExt, "MPEGVideo").ToString();
RegKey.Close();
string tm = new string((char)0, 128);
if (mciSendString("open \"" + File + "\" type " + tp + " alias Media", null, 0, 0) == 0)
{
if (mciSendString("status Media length", tm, tm.Length, 0) == 0)
{
tm = tm.Trim((char)0);
if (!string.IsNullOrEmpty(tm)) RetVal = Convert.ToInt64(tm) / 1000;
}
mciSendString("close Media", null, 0, 0);
}
return RetVal;
}
}
}
//大家好,上面的代码运行时没有提示错误,为什么得到的时间是0秒;麻烦大家一下,怎样修改才能得到歌曲的总时间;
...全文
相关推荐
marker-list:这是(将是)用于在列表中包含标记的聚合物。 主要目的是在与歌曲总时间相比的时间值之后将它们隔开
标记列表 这是(将是)用于在列表中包含标记的聚合物。 主要目的是在与歌曲总时间相比的时间值之后将它们隔开
python-leetcode题解之第1010题总持续时间可被60整除的歌曲.zip
python python_leetcode题解之第1010题总持续时间可被60整除的歌曲.zip
Spotify歌曲数据集.zip
Spotify歌曲数据集.zip
android仿天天动听歌曲自动滚动view
简单实现之天天动听的歌曲自动播放加滑动的效果http://blog.csdn.net/Iamzgx/article/details/51448620
music_player:PyQt5 中的音乐播放器
音乐播放器 PyQt5 中的音乐播放器 什么工作: 从打开的歌曲对话框中选择一首歌曲 播放一首歌 暂停播放的歌曲 停止播放歌曲 增大/减小音量 歌曲进度条 寻求对进度条的控制 当前歌曲的经过时间和总时间 显示当前歌曲信息 10)添加播放列表支持


