zoukankan      html  css  js  c++  java
  • C# mciSendString()实现循环播放音乐

    声明这是 微软论坛上看的. 我看了很多人都在查找C#   mciSendString()循环播放音乐
    学英语重要呀。

    using System;
    using System.Runtime.InteropServices;
    using System.Text;
    using System.Windows.Forms;

    namespace PlayMp3WithWindow
    {
        
    public partial class Form1 : Form
        {
            
    public const int MM_MCINOTIFY = 0x3B9;  //这是声明 播完音乐 mciSendString()向系统发送的指令

            [DllImport(
    "winmm.dll")]
            
    private static extern long mciSendString(string command,
                                                        StringBuilder returnString,
                                                        
    int returnSize,
                                                        IntPtr hwndCallback);
            
    public Form1()
            {
                InitializeComponent();

                PlaySong(
    @"123.mp3");  // when complete callback to DefWndProc

                                                  
    //歌曲路径,开始就播放这个     

            }

            
    protected override void DefWndProc(ref Message m)
            {
                
    base.DefWndProc(ref m);            

            
    if (m.Msg == MM_MCINOTIFY) //判断指令是不是MM_MCINOTIFY

                              
    //当歌曲播完 mciSendString()向系统发送的MM_MCINOTIFY指令
                {
                    PlaySong(
    @"456.mp3");//播完就自动播放这个。。。
                }
            }


            
    public void PlaySong(string file)
            {
                mciSendString(
    "close media"null0, IntPtr.Zero);//关闭
                mciSendString("open \"" + file + "\" type mpegvideo alias media"null0, IntPtr.Zero);

    //打开  file 这个路径的歌曲 " ,type mpegvideo是文件类型  ,    alias 是将文件别名为media 
                mciSendString("play media notify"null0this.Handle);//播放
            }

        }
    }

     seo:http://greatverve.cnblogs.com/archive/2011/06/24/mciSendString.html

    天祺围棋:www.tianqiweiqi.com呵呵

    凡事以大气象去面对,优秀是一种习惯。

  • 相关阅读:
    runas用法
    转:在 DB2 9.7 for Linux, UNIX, and Windows OLTP 环境中使用 EMC Enterprise Flash Drives 的好处
    Dlink路由器的special application 功能
    对称加密和非对称加密
    转:Windows 7加密促使犯罪几率上升
    S60V5版本的手机QQ支持截图、语音和视频功能
    各类存储设备速度比较
    DiffieHellman密钥交换协议工作过程
    转:QQ圈子:社交神器还是隐私魔鬼?
    转:你对存储性能了解多少?
  • 原文地址:https://www.cnblogs.com/greatverve/p/mciSendString.html
Copyright © 2011-2022 走看看