2016年5月3日 星期二

Week 11 張瑋展

作業一
                                                                       打開貝殼專案
                                                                   桌面建立資料夾
將DO,RE,MI.wav檔複製到file
程式碼
                              #include <iostream>
                              #include <windows.h>
                              #include <mmsystem.h>

                              using namespace std;

                              int main()
                              {
                                cout << "Hello world!" << endl;
                                PlaySoundA("Do.wav", NULL, SND_SYNC);
                                PlaySoundA("Re.wav", NULL, SND_SYNC);
                                PlaySoundA("Mi.wav", NULL, SND_SYNC);



                                return 0;
                              }
                                                                            BUILD
                                                                    LINK輸入"winmm"


作業二












影片二


作業三







影片三



#ifndef _MP3_USING_MCI
#define _MP3_USING_MCI

#include <string>
#include <windows.h>
#include <mmsystem.h>
class CMP3_MCI
{
public:
CMP3_MCI(){m_bPaused = false;}
~CMP3_MCI(){Unload();}

inline void Load(char *szFileName)
{
m_szFileName = szFileName;
Load();
}

inline void Load(std::string szFileName)
{
m_szFileName = szFileName;
Load();
}

inline void Play()
{
std::string szCommand = "play " + GetFileName() + " from 0";
mciSendString(szCommand.c_str(), NULL, 0, 0);
}

inline void Stop()
{
std::string szCommand = "stop " + GetFileName();
mciSendString(szCommand.c_str(), NULL, 0, 0);
}

inline void Pause()
{
std::string szCommand;
if(IsPaused())
{
szCommand = "resume " + GetFileName();
mciSendString(szCommand.c_str(), NULL, 0, 0);
SetPaused(false);
}
else
{
szCommand = "pause " + GetFileName();
mciSendString(szCommand.c_str(), NULL, 0, 0);
SetPaused(true);
}
}

inline void Unload()
{
std::string szCommand = "close" + GetFileName();
Stop();
mciSendString(szCommand.c_str(), NULL, 0, 0);
}

//Accessor's for private members.
inline std::string GetFileName()
{return m_szFileName;}

inline bool IsPaused()
{return m_bPaused;}

inline void SetPaused(bool bPaused)
{m_bPaused = bPaused;}
private:
inline void Load()
{
std::string szCommand = "open \"" + GetFileName() + "\" type mpegvideo alias " + GetFileName();
mciSendString(szCommand.c_str(), NULL, 0, 0);
}

std::string m_szFileName;
bool m_bPaused;
};
#endif



沒有留言:

張貼留言