axWindowsMediaPlayer1获取音频长度

  OpenFileDialog openFileDialog1 = new OpenFileDialog
            {
                InitialDirectory = "c:\\",
                Filter = "音频文件(*.mp3,*.s48)|*.Mp3;*.s48",
                FilterIndex = 2,
                RestoreDirectory = true
            };     //显示选择文件对话框
            var path = "";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                path = openFileDialog1.FileName;          //显示文件路径
            }
            if (path.Length == 0)
            {
                MessageBox.Show("您还没有选择任何文件!");
                return;
            }
            IWMPMedia mediaInfo = axWindowsMediaPlayer1.newMedia(path);

            axWindowsMediaPlayer1.URL = path;
            MessageBox.Show(mediaInfo.duration.ToString());

  

posted @ 2014-04-11 17:34  simadi  阅读(709)  评论(0编辑  收藏  举报