#include <QuickTimeComponents.h>
-//Time inbetween timer calls
+//Time between timer calls
#define MOVIE_DELAY 100
+static wxTimer* lastSoundTimer=NULL;
+static bool lastSoundIsPlaying=false;
+
// ------------------------------------------------------------------
// wxQTTimer - Handle Asyncronous Playing
// ------------------------------------------------------------------
class wxQTTimer : public wxTimer
{
public:
- wxQTTimer(Movie movie, bool bLoop, bool& playing) :
- m_movie(movie), m_bLoop(bLoop), m_pbPlaying(&playing)
+ wxQTTimer(Movie movie, bool bLoop, bool* playing) :
+ m_movie(movie), m_bLoop(bLoop), m_pbPlaying(playing)
{
}
class wxSMTimer : public wxTimer
{
public:
- wxSMTimer(void* hSnd, void* pSndChannel, const bool& bLoop, bool& playing)
- : m_hSnd(hSnd), m_pSndChannel(pSndChannel), m_bLoop(bLoop), m_pbPlaying(&playing)
+ wxSMTimer(void* hSnd, void* pSndChannel, bool bLoop, bool* playing)
+ : m_hSnd(hSnd), m_pSndChannel(pSndChannel), m_bLoop(bLoop), m_pbPlaying(playing)
{
}
// ------------------------------------------------------------------
// wxSound
// ------------------------------------------------------------------
-wxTimer* lastSoundTimer=NULL;
-bool lastSoundIsPlaying=false;
//Determines whether version 4 of QT is installed
Boolean wxIsQuickTime4Installed (void)
}
else
{
- wxLogSysError("Quicktime is not installed, or Your Version of Quicktime is <= 4.");
+ wxLogSysError(wxT("Quicktime is not installed, or Your Version of Quicktime is <= 4."));
return false;
}
}
wxSound::~wxSound()
{
- if(lastSoundIsPlaying)
- {
- if(m_type == wxSound_RESOURCE)
- ((wxSMTimer*)lastSoundTimer)->m_pbPlaying = NULL;
- else
- ((wxQTTimer*)lastSoundTimer)->m_pbPlaying = NULL;
- }
}
bool wxSound::Create(const wxString& fileName, bool isResource)
wxMacStringToPascal( fileName , lpSnd ) ;
- m_sndname = lpSnd;
+ m_sndname = fileName;
m_hSnd = (char*) GetNamedResource('snd ', (const unsigned char *) lpSnd);
#else
return false;
miComponent = OpenDefaultComponent(MovieImportType, kQTFileTypeAIFC);
else
{
- wxLogSysError("wxSound - Location in memory does not contain valid data");
+ wxLogSysError(wxT("wxSound - Location in memory does not contain valid data"));
return false;
}
{
lastSoundTimer = ((wxSMTimer*&)m_pTimer)
= new wxSMTimer(pSndChannel, m_hSnd, flags & wxSOUND_LOOP ? 1 : 0,
- lastSoundIsPlaying=true);
+ &lastSoundIsPlaying);
+ lastSoundIsPlaying = true;
((wxTimer*)m_pTimer)->Start(MOVIE_DELAY, wxTIMER_CONTINUOUS);
}
return false;
}//end switch(m_type)
-
//Start the movie!
StartMovie(movie);
- if (flags & wxSOUND_SYNC)
+ if (flags & wxSOUND_ASYNC)
+ {
+ //Start timer and play movie asyncronously
+ lastSoundTimer = ((wxQTTimer*&)m_pTimer) =
+ new wxQTTimer(movie, flags & wxSOUND_LOOP ? 1 : 0,
+ &lastSoundIsPlaying);
+ lastSoundIsPlaying = true;
+ ((wxQTTimer*)m_pTimer)->Start(MOVIE_DELAY, wxTIMER_CONTINUOUS);
+ }
+ else
{
- wxASSERT_MSG(!(flags & wxSOUND_LOOP), "Can't loop and play syncronously at the same time");
+ wxASSERT_MSG(!(flags & wxSOUND_LOOP), wxT("Can't loop and play syncronously at the same time"));
//Play movie until it ends, then exit
while (!IsMovieDone(movie))
DisposeMovie(movie);
}
- else
- {
- //Start timer and play movie asyncronously
- lastSoundTimer = ((wxQTTimer*&)m_pTimer) = new wxQTTimer(movie, flags & wxSOUND_LOOP ? 1 : 0,lastSoundIsPlaying=true);
- ((wxQTTimer*)m_pTimer)->Start(MOVIE_DELAY, wxTIMER_CONTINUOUS);
- }
return true;
}
void wxSound::Stop()
{
- if(lastSoundIsPlaying)
+ if (lastSoundIsPlaying)
{
delete (wxTimer*&) lastSoundTimer;
lastSoundIsPlaying = false;
+ lastSoundTimer = NULL;
}
}