Esempio n. 1
0
void Animation::Advance(const float& advancement)
{
	if (advancement == 0.0f)
		return;
	if (mCurrentFrame == mFrames.end())
		mCurrentFrame = mFrames.begin();
	mCurrentTime += advancement;

	if ( mFrames.empty() )
		return; // nothing to do 

	if ( (*mCurrentFrame)->mFrameTime + advancement <= (*mCurrentFrame)->mFrameLength && (*mCurrentFrame)->mFrameTime + advancement > 0.0f)
	{
		(*mCurrentFrame)->mFrameTime += advancement;
		return;
	}
	
	//if ( mCurrentTime < 0.0f )
		//mCurrentTime = mAnimationLength - (fmod(abs(mCurrentTime),mAnimationLength));
	if ( mCurrentTime > mAnimationLength )
		mCurrentTime = fmod( mCurrentTime, mAnimationLength );

	SeekToTime(mCurrentTime);

}
Esempio n. 2
0
MEDIACODEC_API void ReadReset(MediaFormatContext_t* ctx){
	SeekToTime(ctx,0);
}
bool VideoTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame, bool freezeMusic, bool looping, uint32 startTime, float forceZoom, int volume) {
    if (forceZoom < 0.0f) {
        forceZoom = 100.0f;
    }
    if (volume < 0) {
        _volume = _gameRef->_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType);
    } else {
        _volume = volume;
    }

    _freezeGame = freezeGame;

    if (!_playbackStarted && _freezeGame) {
        _gameRef->freeze(freezeMusic);
    }

    _playbackStarted = false;
    float width, height;
    if (_theoraDecoder) {
        _surface.free();
        _surface.copyFrom(*_theoraDecoder->decodeNextFrame());
        _state = THEORA_STATE_PLAYING;
        _looping = looping;
        _playbackType = type;

        _startTime = startTime;
        _volume = volume;
        _posX = x;
        _posY = y;
        _playZoom = forceZoom;

        width = (float)_theoraDecoder->getWidth();
        height = (float)_theoraDecoder->getHeight();
    } else {
        width = (float)_gameRef->_renderer->getWidth();
        height = (float)_gameRef->_renderer->getHeight();
    }

    switch (type) {
    case VID_PLAY_POS:
        _playZoom = forceZoom;
        _posX = x;
        _posY = y;
        break;

    case VID_PLAY_STRETCH: {
        float zoomX = (float)((float)_gameRef->_renderer->getWidth() / width * 100);
        float zoomY = (float)((float)_gameRef->_renderer->getHeight() / height * 100);
        _playZoom = MIN(zoomX, zoomY);
        _posX = (int)((_gameRef->_renderer->getWidth() - width * (_playZoom / 100)) / 2);
        _posY = (int)((_gameRef->_renderer->getHeight() - height * (_playZoom / 100)) / 2);
    }
    break;

    case VID_PLAY_CENTER:
        _playZoom = 100.0f;
        _posX = (int)((_gameRef->_renderer->getWidth() - width) / 2);
        _posY = (int)((_gameRef->_renderer->getHeight() - height) / 2);
        break;
    }
    _theoraDecoder->start();

    return STATUS_OK;
#if 0 // Stubbed for now as theora isn't seekable
    if (StartTime) SeekToTime(StartTime);

    Update();
#endif
    return STATUS_FAILED;
}