AnimationPlayer = {}

function AnimationPlayer:start(filename)
  self:stop()
  local animation = gr.loadStreamingAnim(filename)
  if not animation:isValid() then
    ba.error('Could not load streaming animation ' .. filename)
  end
  self._animation = animation
  self._width = gr.getScreenWidth()
  self._height = gr.getScreenHeight()
end

function AnimationPlayer:stop()
  if self._animation then
    self._animation:unload()
  end
end

function AnimationPlayer:onFrame()
  if self._animation then
    self._animation:process(0, 0, self._width, self._height)
  end
end

