My Documents/dxframework/dxf/dxf-engine/dxf_sound.cpp

Go to the documentation of this file.
00001 /*      DXFramework Copyright (c) 2006, Jonathan Voigt, University of Michigan.
00002         See http://dxframework.sourceforge.net/ for a list of contributors.
00003         All rights reserved.
00004 
00005         Redistribution and use in source and binary forms, with or without modification, 
00006         are permitted provided that the following conditions are met:
00007 
00008                 * Redistributions of source code must retain the above copyright notice, 
00009                 this list of conditions and the following disclaimer.
00010 
00011                 * Redistributions in binary form must reproduce the above copyright notice, 
00012                 this list of conditions and the following disclaimer in the documentation 
00013                 and/or other materials provided with the distribution.
00014 
00015                 * Neither the name of the DXFramework project nor the names of its 
00016                 contributors may be used to endorse or promote products derived from this 
00017                 software without specific prior written permission.
00018 
00019         THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
00020         ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
00021         WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
00022         DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 
00023         ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
00024         (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
00025         LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
00026         ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
00027         (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
00028         SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 */
00030 
00031 #include "dxframework.h"
00032 
00033 namespace dxf {
00034         CSoundManager* Sound::pManager = 0;
00035 
00036         void Sound::SetManager(CSoundManager* pManager) {
00037                 Sound::pManager = pManager;
00038         }
00039 
00040         Sound::Sound() {
00041                 pSound = 0;
00042         }
00043 
00044         HRESULT Sound::Load(const std::wstring& filename) {
00045                 assert(!pSound);
00046 
00047                 //std::wstring pathname(L"media/");
00048                 //pathname += filename;
00049                 WCHAR strPath[MAX_PATH];
00050                 HRESULT hr = DXUTFindDXSDKMediaFileCch( strPath, MAX_PATH, filename.c_str() );
00051                 if( FAILED(hr) )
00052                 {
00053                         return DXTRACE_ERR( L"DXUTFindDXSDKMediaFileCch", hr );
00054                 }
00055 
00056                 V_RETURN(pManager->Create(&pSound, strPath));
00057                 return S_OK;
00058         }
00059 
00060         void Sound::Unload() {
00061                 SAFE_DELETE(pSound);
00062         }
00063 
00064         void Sound::Play(bool stopFirst) {
00065                 if (stopFirst) DXUT_StopSound(pSound);
00066                 DXUT_PlaySound(pSound);
00067         }
00068 
00069         void Sound::PlayLooping() {
00070                 DXUT_PlaySoundLooping(pSound);
00071         }
00072 
00073         void Sound::Stop() {
00074                 DXUT_StopSound(pSound);
00075         }
00076 
00077         bool Sound::IsPlaying() {
00078                 return pSound->IsSoundPlaying() ? true : false;
00079         }
00080 } // namespace dxf

Generated on Fri Aug 18 12:01:27 2006 for DXFramework by  doxygen 1.4.7