mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-18 19:29:09 +00:00
Implement Pause
Also, do not show the plate before there is anything on it.
This commit is contained in:
@ -171,9 +171,11 @@ plMoviePlayer::plMoviePlayer() :
|
|||||||
fPlate(nullptr),
|
fPlate(nullptr),
|
||||||
fTexture(nullptr),
|
fTexture(nullptr),
|
||||||
fReader(nullptr),
|
fReader(nullptr),
|
||||||
fStartTime(0),
|
fMovieTime(0),
|
||||||
|
fLastFrameTime(0),
|
||||||
fPosition(hsPoint2()),
|
fPosition(hsPoint2()),
|
||||||
fPlaying(false),
|
fPlaying(false),
|
||||||
|
fPaused(false),
|
||||||
fOpusDecoder(nullptr)
|
fOpusDecoder(nullptr)
|
||||||
{
|
{
|
||||||
fScale.Set(1.0f, 1.0f);
|
fScale.Set(1.0f, 1.0f);
|
||||||
@ -195,11 +197,6 @@ plMoviePlayer::~plMoviePlayer()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t plMoviePlayer::GetMovieTime() const
|
|
||||||
{
|
|
||||||
return (int64_t)hsTimer::GetMilliSeconds() - fStartTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool plMoviePlayer::IOpenMovie()
|
bool plMoviePlayer::IOpenMovie()
|
||||||
{
|
{
|
||||||
#ifdef VIDEO_AVAILABLE
|
#ifdef VIDEO_AVAILABLE
|
||||||
@ -285,6 +282,7 @@ void plMoviePlayer::IProcessVideoFrame(const std::vector<blkbuf_t>& frames)
|
|||||||
// Flush new data to the device
|
// Flush new data to the device
|
||||||
if (fTexture->GetDeviceRef())
|
if (fTexture->GetDeviceRef())
|
||||||
fTexture->GetDeviceRef()->SetDirty(true);
|
fTexture->GetDeviceRef()->SetDirty(true);
|
||||||
|
fPlate->SetVisible(true);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -334,8 +332,7 @@ bool plMoviePlayer::Start()
|
|||||||
float height = (static_cast<float>(video->GetHeight()) / static_cast<float>(plateMgr.GetPipeHeight())) * fScale.fY;
|
float height = (static_cast<float>(video->GetHeight()) / static_cast<float>(plateMgr.GetPipeHeight())) * fScale.fY;
|
||||||
|
|
||||||
plateMgr.CreatePlate(&fPlate, fPosition.fX, fPosition.fY, width, height);
|
plateMgr.CreatePlate(&fPlate, fPosition.fX, fPosition.fY, width, height);
|
||||||
fPlate->SetVisible(true);
|
fTexture = fPlate->CreateMaterial(static_cast<uint32_t>(video->GetWidth()), static_cast<uint32_t>(video->GetHeight()), false);
|
||||||
fTexture = fPlate->CreateMaterial(static_cast<uint32_t>(video->GetWidth()), static_cast<uint32_t>(video->GetHeight()), nullptr);
|
|
||||||
|
|
||||||
//initialize opus
|
//initialize opus
|
||||||
const mkvparser::AudioTrack* audio = static_cast<const mkvparser::AudioTrack*>(fAudioTrack->GetTrack());
|
const mkvparser::AudioTrack* audio = static_cast<const mkvparser::AudioTrack*>(fAudioTrack->GetTrack());
|
||||||
@ -352,6 +349,7 @@ bool plMoviePlayer::Start()
|
|||||||
if (error != OPUS_OK)
|
if (error != OPUS_OK)
|
||||||
hsAssert(false, "Error occured initalizing opus");
|
hsAssert(false, "Error occured initalizing opus");
|
||||||
|
|
||||||
|
fLastFrameTime = static_cast<int64_t>(hsTimer::GetMilliSeconds());
|
||||||
fPlaying = true;
|
fPlaying = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -365,25 +363,28 @@ bool plMoviePlayer::NextFrame()
|
|||||||
if (!fPlaying)
|
if (!fPlaying)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
int64_t frameTime = static_cast<int64_t>(hsTimer::GetMilliSeconds());
|
||||||
|
int64_t frameTimeDelta = frameTime - fLastFrameTime;
|
||||||
|
fLastFrameTime = frameTime;
|
||||||
|
|
||||||
|
if (fPaused)
|
||||||
|
return true;
|
||||||
|
|
||||||
#ifdef VIDEO_AVAILABLE
|
#ifdef VIDEO_AVAILABLE
|
||||||
// Get our current timecode
|
// Get our current timecode
|
||||||
int64_t movieTime = 0;
|
fMovieTime += frameTimeDelta;
|
||||||
if (fStartTime == 0)
|
|
||||||
fStartTime = static_cast<int64_t>(hsTimer::GetMilliSeconds());
|
|
||||||
else
|
|
||||||
movieTime = GetMovieTime();
|
|
||||||
|
|
||||||
std::vector<blkbuf_t> audio;
|
std::vector<blkbuf_t> audio;
|
||||||
std::vector<blkbuf_t> video;
|
std::vector<blkbuf_t> video;
|
||||||
uint8_t tracksWithData = 0;
|
uint8_t tracksWithData = 0;
|
||||||
if (fAudioTrack)
|
if (fAudioTrack)
|
||||||
{
|
{
|
||||||
if (fAudioTrack->GetFrames(fReader, movieTime, audio))
|
if (fAudioTrack->GetFrames(fReader, fMovieTime, audio))
|
||||||
tracksWithData++;
|
tracksWithData++;
|
||||||
}
|
}
|
||||||
if (fVideoTrack)
|
if (fVideoTrack)
|
||||||
{
|
{
|
||||||
if (fVideoTrack->GetFrames(fReader, movieTime, video))
|
if (fVideoTrack->GetFrames(fReader, fMovieTime, video))
|
||||||
tracksWithData++;
|
tracksWithData++;
|
||||||
}
|
}
|
||||||
if (!tracksWithData)
|
if (!tracksWithData)
|
||||||
@ -402,11 +403,22 @@ bool plMoviePlayer::NextFrame()
|
|||||||
#endif // VIDEO_AVAILABLE
|
#endif // VIDEO_AVAILABLE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool plMoviePlayer::Pause(bool on)
|
||||||
|
{
|
||||||
|
if (!fPlaying)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
fPaused = on;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool plMoviePlayer::Stop()
|
bool plMoviePlayer::Stop()
|
||||||
{
|
{
|
||||||
fPlaying = false;
|
fPlaying = false;
|
||||||
if (fAudioSound)
|
if (fAudioSound)
|
||||||
fAudioSound->Stop();
|
fAudioSound->Stop();
|
||||||
|
if (fPlate)
|
||||||
|
fPlate->SetVisible(false);
|
||||||
for (int i = 0; i < fCallbacks.size(); i++)
|
for (int i = 0; i < fCallbacks.size(); i++)
|
||||||
fCallbacks[i]->Send();
|
fCallbacks[i]->Send();
|
||||||
fCallbacks.clear();
|
fCallbacks.clear();
|
||||||
|
@ -79,13 +79,13 @@ protected:
|
|||||||
std::unique_ptr<class VPX> fVpx;
|
std::unique_ptr<class VPX> fVpx;
|
||||||
class OpusDecoder* fOpusDecoder;
|
class OpusDecoder* fOpusDecoder;
|
||||||
|
|
||||||
int64_t fStartTime;
|
int64_t fMovieTime, fLastFrameTime;
|
||||||
hsPoint2 fPosition, fScale;
|
hsPoint2 fPosition, fScale;
|
||||||
plFileName fMoviePath;
|
plFileName fMoviePath;
|
||||||
|
|
||||||
bool fPlaying;
|
bool fPlaying;
|
||||||
|
bool fPaused;
|
||||||
|
|
||||||
int64_t GetMovieTime() const;
|
|
||||||
bool IOpenMovie();
|
bool IOpenMovie();
|
||||||
void IProcessVideoFrame(const std::vector<blkbuf_t>& frames);
|
void IProcessVideoFrame(const std::vector<blkbuf_t>& frames);
|
||||||
void IProcessAudioFrame(const std::vector<blkbuf_t>& frames);
|
void IProcessAudioFrame(const std::vector<blkbuf_t>& frames);
|
||||||
@ -95,7 +95,7 @@ public:
|
|||||||
~plMoviePlayer();
|
~plMoviePlayer();
|
||||||
|
|
||||||
bool Start();
|
bool Start();
|
||||||
bool Pause(bool on) { return false; }
|
bool Pause(bool on);
|
||||||
bool Stop();
|
bool Stop();
|
||||||
bool NextFrame();
|
bool NextFrame();
|
||||||
|
|
||||||
@ -108,6 +108,8 @@ public:
|
|||||||
|
|
||||||
void SetColor(const hsColorRGBA& c) { }
|
void SetColor(const hsColorRGBA& c) { }
|
||||||
const hsColorRGBA GetColor() const { return hsColorRGBA(); }
|
const hsColorRGBA GetColor() const { return hsColorRGBA(); }
|
||||||
|
|
||||||
|
/** The volume is handled by the options menu slider, as of now. */
|
||||||
void SetVolume(float v) { }
|
void SetVolume(float v) { }
|
||||||
|
|
||||||
hsPoint2 GetPosition() const { return fPosition; }
|
hsPoint2 GetPosition() const { return fPosition; }
|
||||||
|
Reference in New Issue
Block a user