现在的位置: 首页 > 综合 > 正文

DiriectX播放mp3

2013年08月19日 ⁄ 综合 ⁄ 共 919字 ⁄ 字号 评论关闭

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 Microsoft.DirectX.DirectSound;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                string filename = @"D:/Project/Study2008/WindowsFormsApplication1/bin/Debug/phone.mp3";
                Device device = new Device();
                device.SetCooperativeLevel(this, CooperativeLevel.Priority);
                SecondaryBuffer buffer = new SecondaryBuffer(filename, device);
               
                buffer.Play(0, BufferPlayFlags.Looping);
              
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}

 

抱歉!评论已关闭.