2
// libavg - Media Playback Engine.
3
// Copyright (C) 2003-2008 Ulrich von Zadow
5
// This library is free software; you can redistribute it and/or
6
// modify it under the terms of the GNU Lesser General Public
7
// License as published by the Free Software Foundation; either
8
// version 2 of the License, or (at your option) any later version.
10
// This library is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
// Lesser General Public License for more details.
15
// You should have received a copy of the GNU Lesser General Public
16
// License along with this library; if not, write to the Free Software
17
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
// Current versions can be found at www.libavg.de
23
#include "../base/Exception.h"
24
#include "../base/ObjectCounter.h"
26
#include "../player/Player.h"
28
using namespace boost::python;
33
Anim::Anim(const object& startCallback, const object& stopCallback)
34
: m_StartCallback(startCallback),
35
m_StopCallback(stopCallback),
39
ObjectCounter::get()->incRef(&typeid(*this));
44
ObjectCounter::get()->decRef(&typeid(*this));
47
void Anim::setStartCallback(const object& startCallback)
49
m_StartCallback = startCallback;
52
void Anim::setStopCallback(const object& stopCallback)
54
m_StopCallback = stopCallback;
57
void Anim::start(bool)
60
throw(Exception(AVG_ERR_UNSUPPORTED,
61
"Anim.start(): animation already running."));
63
if (!(Player::get()->isPlaying())) {
64
throw(Exception(AVG_ERR_UNSUPPORTED,
65
"Animation playback can only be started when the player is running."));
69
Player::get()->registerPreRenderListener(this);
71
if (m_StartCallback != object()) {
72
call<void>(m_StartCallback.ptr());
76
bool Anim::isRunning() const
81
void Anim::setHasParent()
87
void Anim::onPreRender()
92
void Anim::setStopped()
95
Player::get()->unregisterPreRenderListener(this);
98
if (m_StopCallback != object()) {
99
call<void>(m_StopCallback.ptr());