2018年5月18日 星期五

week12_洪梓菱



             
(1)在程式中加入     
#include <mmsystem.h>///多媒體系統才會有PlaySound()

PlaySound("bubbs.wav", NULL, SND_ASYNC | SND_LOOP);///PlaySound播放多媒體的聲音

這兩行程式碼使音樂可以播放
要記得將音檔放入freeglut的bin資料夾


(2)先到moodle下載CMP3_MCI.h作為MP3的外掛


(3)加入以下程式
#include "CMP3_MCI.h"///MP3外掛
CMP3_MCI myMP3; ///Now: 宣告物件變數
int a;
float b;
char c;

myMP3.Load("finish.mp3");
    myMP3.Play();
要將音樂檔放入bin資料夾,使mp3可以播放


計時器
 
#include <windows.h>///因為mmsystem.h, 需要windows.h
#include <mmsystem.h>///多媒體系統才會有PlaySound()
#include <stdio.h>
void timer(int t)
{
    printf("%d\n", t);
    glutTimerFunc(1000, timer, t+1);
    PlaySound("bubbs.wav", NULL, SND_ASYNC);
}


glutTimerFunc(5000, timer, 0);

沒有留言:

張貼留言