如何理解音乐的长度 [英] How to understand the lengh fi a music

查看:93
本文介绍了如何理解音乐的长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨...

之前有这个问题,所以有人帮我!!!
但是答案不是我的问题的答案,我想知道音乐的长度,但是这段代码给了我音乐的分量(以字节为单位)...

Hi...

before a had this question so someones help me!!!
but the answers wasn''t answer of my question, i want to know the length of a music but this code give me the weight of a music (in bytes)...

OpenFileDialog dlgOpenFile = new OpenFileDialog();

            String filepath = "";
            string[] str;
            string nomeFich = "";
            dlgOpenFile.Filter = ("MP3 files (*.mp3)|*.mp3");

            if (dlgOpenFile.ShowDialog() == DialogResult.OK)
            {
                filepath = dlgOpenFile.FileName;

                long fileSize = 0;

                System.IO.FileInfo fi = new FileInfo(filepath);

                fileSize = fi.Length;

                progressBar1.Minimum = 0;

                progressBar1.Maximum = (int)fileSize;

                fileSize = fileSize / 1000000;

                for (int indice = 0; indice < fileSize; indice++)
                {
                    progressBar1.Value = indice;

                    SoundPlayer.URL = odf.FileName; 

                } 


在这里fileSize给我音乐的大小(例如5667434)_in bytes_;
如果此代码是错误的,那是什么问题,如果要进行此工作,我们需要另一个代码是什么?

祝你好运!


Here fileSize give me the size of music (e.g 5667434)_in bytes_;
if this code is wrong what''s the problem , if for this work we need another code what is it?

Good Luck!

推荐答案


如果您想要音频文件的长度,则应读取其基础标签(对于mp3格式,其ID3标签).为此目的,有一个很好的库: http://www.novell.com/products /linuxpackages/opensuse11.1/taglib-sharp.html [
Hi,
If you want the length of the audio file than you should reads it''s underlying tags (for mp3 format its ID3 tags). There is a good library for this purpose: http://www.novell.com/products/linuxpackages/opensuse11.1/taglib-sharp.html[^]
Regards


这篇关于如何理解音乐的长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆