1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【C#】wavファイルを鳴らす

Posted at

###表題のまんまなのでいきなり本文

using System.Media;

namespace app
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            string path = @"D:\exe\visualstudiocommunity\hogefuga\music.wav";
            SountPlayer music = new SoundPlayer(path);
            music.Play();
        }
    }
}

visual studio communityでF5を押下してビルドすると音楽が鳴ります。
勿論pathの部分は自分の環境にあったものを入れてください。

前回unityでゲーム作ろう!って記事を書いたのですが、そもそもC#なんぞやという状態だったので、まず素のC#で何か作ってみようと思いました。。
物理演算とかしないなら普通に作れますよね。まあunity使う気なら最初からunityで作ってもいいと思うのですが、覚えることが多そうなので先にプログラムだけ学ぼうと思います。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?