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呵呵

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

  • 相关阅读:
    多组件共享-vuex —— 使用vuex 报错 actions should be function or object with ”handler“
    时间复杂度/空间复杂度
    Nodejs学习(三)-安装nodejs supervisor,提高点效率吧。
    Nodejs学习(二)-express生成器
    Nodejs学习(一)-Nodejs和express的安装和配置
    PHP连接MySQL的时候报错SQLSTATE[HY000] [2002] No such file or directory
    phpstorm 16.1 注册码
    Express安装过程
    NodeJs解析web一例
    NodeJs 连接mysql一例。
  • 原文地址:https://www.cnblogs.com/greatverve/p/mciSendString.html
Copyright © 2011-2022 走看看