请问什么算法才能计算出一首MP3歌曲的时间长度?

quickball 2002-05-13 09:44:28
谢谢!
...全文
83 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
zzwu 2002-05-14
  • 打赏
  • 举报
回复
以下这一段Delphi程序可以把当前打开的media的所需播放时间用HMS(时分秒)的方式显示出来,主要利用的是MediaPlayer1.Length特性,其余只是格式转换。

type
HMSRec = record
Hours: byte;
Minutes: byte;
Seconds: byte;
NotUsed: byte;
end;

procedure TForm1.Button1Click(Sender: TObject);

var
TheLength: LongInt;
begin
{ Set time format - note that some devices don抰 support tfHMS }
MediaPlayer1.TimeFormat := tfHMS;
{ Store length of currently loaded media }
TheLength := MediaPlayer1.Length;
with HMSRec(TheLength) do { Typecast TheLength as a HMSRec record }
begin
Label1.Caption := IntToStr(Hours); { Display Hours in Label1 }
Label2.Caption := IntToStr(Minutes); { Display Minutes in Label2 }
Label3.Caption := IntToStr(Seconds); { Display Seconds in Label3 }
end;
end;
qingfeng5008080 2002-05-14
  • 打赏
  • 举报
回复
晕死~~~~~~~~~~~~~~~~~~~~~~~~~~~~
starfish 2002-05-14
  • 打赏
  • 举报
回复
在mp3文件头的信息块中包含长度信息,可以使用direct x 的api直接读入一个mp3文件的信息。你看一下相关的windows api吧,查查msdn

不过你这个问题似乎问错了地方。
chenxianwen 2002-05-13
  • 打赏
  • 举报
回复
最简单:用winamp,可以自动计算。
iProgram 2002-05-13
  • 打赏
  • 举报
回复
faint,想不到我逃到算法版还能够看到MP3的问题:)

这个要看MP3的Frame结构相关的知识吧,和这个版没太大关系。有耐心的话看看freeamp的代码

33,027

社区成员

发帖
与我相关
我的任务
社区描述
数据结构与算法相关内容讨论专区
社区管理员
  • 数据结构与算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧