Debian Codegraph @

src/state/MovieState.cpp

raw
1 /*
2 * Copyright (C) 2009 Ivo Danihelka ([email protected])
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 */
9 #ifdef HAVE_SMPEG
10 #include "MovieState.h"
11
12 #include "SDL_Movie.h"
13 #include "DemoInput.h"
14
15 #include "OptionAgent.h"
16 #include "VideoAgent.h"
17 #include "SoundAgent.h"
18
19 //-----------------------------------------------------------------
20 MovieState::MovieState(const Path &file)
21 : m_file(file)
22 {
23 takeHandler(new DemoInput(this));
24 }
25 //-----------------------------------------------------------------
26 void
27 MovieState::own_initState()
28 {
29 SoundAgent::agent()->stopMusic();
30 Mix_CloseAudio();
31 m_movie = new SDL_Movie();
32 m_movie->Load(m_file.getNative().c_str());
33
34 SMPEG_Info info = m_movie->GetInfo();
35 OptionAgent *options = OptionAgent::agent();
36 options->setParam("screen_width", info.width);
37 options->setParam("screen_height", info.height);
38 VideoAgent::agent()->initVideoMode();
39
40 m_movie->Play();
41 registerDrawable(m_movie);
42 }
43 //-----------------------------------------------------------------
44 void
45 MovieState::own_updateState()
46 {
47 if(m_movie->GetStatus() != SMPEG_PLAYING) {
48 quitState();
49 }
50 }
51 //-----------------------------------------------------------------
52 void
53 MovieState::own_cleanState()
54 {
55 delete m_movie;
56 SoundAgent::agent()->reinit();
57 }
58
59 #endif