// SoundWAVStop.cpp : メイン プロジェクト ファイルです。

#include "stdafx.h"

using namespace System;
using namespace System::Media;
using namespace System::Threading;

int main(array<System::String ^> ^args)
{
    String^ path = "xmas004.wav";
	SoundPlayer^ wavePlayer = gcnew SoundPlayer(path);
	wavePlayer->PlayLooping();
	
	// サウンド再生中も以降の処理を実行する
	for (int i = 1; i <= 25; i++) {
		Thread::Sleep(1000);
		Console::WriteLine(i + "秒経過");
		
		// 20秒経過後に再生をストップする
		if (i == 20) {
			wavePlayer->Stop(); // 再生をストップ
			Console::WriteLine("再生停止");
		}
	}
	
	return 0;
}