Restart play when at end

This commit is contained in:
Matthias Neeracher 2008-07-06 11:07:57 +00:00
parent b68fc2dd5a
commit 74cb6433b4
3 changed files with 13 additions and 1 deletions

View File

@ -588,6 +588,8 @@
VLSoundOut::Instance()->SetPlayRate(playRate = 1.0f); VLSoundOut::Instance()->SetPlayRate(playRate = 1.0f);
if (!nowPlaying) if (!nowPlaying)
[self play:sender]; [self play:sender];
else if (VLSoundOut::Instance()->AtEnd())
VLSoundOut::Instance()->SetTime(0);
break; break;
case 1: // Fwd case 1: // Fwd
case -1: // Rew case -1: // Rew
@ -604,6 +606,8 @@
VLSoundOut::Instance()->SetPlayRate(playRate*tempoRate); VLSoundOut::Instance()->SetPlayRate(playRate*tempoRate);
break; break;
case -2: // To Start case -2: // To Start
if (playRate < 0)
VLSoundOut::Instance()->SetPlayRate(playRate = -playRate);
VLSoundOut::Instance()->SetTime(0); VLSoundOut::Instance()->SetTime(0);
break; break;
case 2: // To End case 2: // To End

View File

@ -29,6 +29,7 @@ public:
virtual void PlaySequence(MusicSequence music); virtual void PlaySequence(MusicSequence music);
virtual void Stop(bool pause); virtual void Stop(bool pause);
virtual bool Playing(); virtual bool Playing();
virtual bool AtEnd();
virtual void SetPlayRate(float rate); virtual void SetPlayRate(float rate);
virtual void SetTime(MusicTimeStamp time); virtual void SetTime(MusicTimeStamp time);
@ -218,7 +219,6 @@ void VLAUSoundOut::SetPlayRate(float rate)
void VLAUSoundOut::SetTime(MusicTimeStamp time) void VLAUSoundOut::SetTime(MusicTimeStamp time)
{ {
SetPlayRate(1.0f);
MusicPlayerSetTime(fPlayer, time); MusicPlayerSetTime(fPlayer, time);
} }
@ -238,6 +238,13 @@ bool VLAUSoundOut::Playing()
return fRunning; return fRunning;
} }
bool VLAUSoundOut::AtEnd()
{
MusicTimeStamp time;
return !MusicPlayerGetTime(fPlayer, &time) && time >= fMusicLength;
}
void VLAUSoundOut::PlayNote(const VLNote & note) void VLAUSoundOut::PlayNote(const VLNote & note)
{ {
Play(&note.fPitch); Play(&note.fPitch);

View File

@ -41,6 +41,7 @@ public:
virtual void PlaySequence(MusicSequence music) = 0; virtual void PlaySequence(MusicSequence music) = 0;
virtual void Stop(bool pause=true) = 0; virtual void Stop(bool pause=true) = 0;
virtual bool Playing() = 0; virtual bool Playing() = 0;
virtual bool AtEnd() = 0;
virtual void SetPlayRate(float rate) = 0; virtual void SetPlayRate(float rate) = 0;
virtual void SetTime(MusicTimeStamp time) = 0; virtual void SetTime(MusicTimeStamp time) = 0;