zoukankan      html  css  js  c++  java
  • winform窗体添加背景音乐(三种方式)

    winform窗体添加背景音乐(三种方式)

     1:使用控件Microsoft   MutileMedia   Control   Version   6.0,可在Vs.net中添加此控件.
       取名为player.  
          '播放背景音乐  
                                            player.FileName   =   Application.StartupPath "/Music/GameMain.mid"  
                                             player.Command   =   "Open"  
                                           player.Command   =   "Play"
    这种方法我测试过就可以播放wma和wmv格式的音乐文件,而且在播放wmv的时候会新建窗口


    2.你可以用 directx 9 的托管DirectX.AudioVideoPlayback.DLL里面有个类命,你可以在C:的Microsoft.net的文件夹里面找到这个文件,用这个类Audio,用来播放音

    乐很方便,
    Audio v=Audio(".mp3");
    v.ending +=new .....//添加事件处理函数!

    在他的事件处理函数里可以写
    v.open("声音文件名!")
    v.play();
    详细的可以自己处理一下就行了! 

    3.可以使用SoundPlayer.PlaySync 方法 来异步加载文件并播放.

    --------------------------------------------------------------------------------
    如何在Winform环境下,给窗体添加背景音乐?

    比如:
    private SoundPlayer Player = new SoundPlayer();//首先NEW一个播放器
    private void loadSoundAsync()
    {
    // Note: You may need to change the location specified based on
    // the location of the sound to be played.
    this.Player.SoundLocation = "http://www.tailspintoys.com/sounds/stop.wav";
    this.Player.LoadAsync();
    }

    private void Player_LoadCompleted(
    object sender,
    System.ComponentModel.AsyncCompletedEventArgs e)
    {
    if (this.Player.IsLoadCompleted)
    {
    this.Player.PlaySync();
    }
    }

    //比如这是在本地找的背景
    this.axWindowsMediaPlayer1.URL = @"F:/MS/09 老鼠愛大米.mp3";
    this.axWindowsMediaPlayer1.Visible=false;

  • 相关阅读:
    机器学习项目流程
    机器学习之数据归一化问题
    python三数之和
    从不订购的客户
    case when then的用法-leetcode交换工资
    .NET Core Api 集成 swagger
    .NET CORE 2.1 导出excel文件的两种方法
    Dapper的基本使用
    (转)深入研究MiniMVC之后续篇
    (转)深入研究 蒋金楠(Artech)老师的 MiniMvc(迷你 MVC),看看 MVC 内部到底是如何运行的
  • 原文地址:https://www.cnblogs.com/baishiying/p/2662114.html
Copyright © 2011-2022 走看看