Index: trunk/src/lib/graphics/importer/media_container.cc
===================================================================
--- trunk/src/lib/graphics/importer/media_container.cc	(revision 6729)
+++ trunk/src/lib/graphics/importer/media_container.cc	(revision 6731)
@@ -40,18 +40,7 @@
 
   fps = 0;
-
-  if (filename != NULL)
-  {
-    if(!this->loadMedia(filename))
-      PRINTF(1)("MediaContainer::loadMedia() failed for %s\n", filename);
-  }
-}
-
-MediaContainer::MediaContainer()
-{
-  // set the class id for the base object
-  this->setClassID(CL_MEDIA_CONTAINER, "MediaContainer");
-
-  fps = 0;
+  mediaLoaded = false;
+
+  this->loadMedia(filename);
 }
 
@@ -61,6 +50,20 @@
 MediaContainer::~MediaContainer()
 {
+  this->unloadMedia();
+}
+
+void MediaContainer::unloadMedia()
+{
+  // check whether a movie is already loaded
+  if(!mediaLoaded)
+    return;
+
+  fps = 0;
+
+  // clear texturelist
+  this->clearLists();
+
   if (glIsTexture(texture))
-    glDeleteTextures(1, &texture);
+  glDeleteTextures(1, &texture);
 
   // Free the RGB image
@@ -76,8 +79,22 @@
   // Close the video file
   av_close_input_file(format_context);
+
+  mediaLoaded = false;
+
 }
 
 bool MediaContainer::loadMedia(const char* filename)
 {
+  this->unloadMedia();
+
+  if(filename == NULL)
+    return false;
+  // check whether file exists
+  if(!ResourceManager::isInDataDir(filename))
+  {
+    PRINTF(1)("Could not find %s\n", filename);
+    return false;
+  }
+
   // register all formats and codecs
   av_register_all();
@@ -146,4 +163,5 @@
   // read the frames and save them in a sequence as textures
   this->loadFrames();
+  mediaLoaded = true;
 
   return true;
Index: trunk/src/lib/graphics/importer/media_container.h
===================================================================
--- trunk/src/lib/graphics/importer/media_container.h	(revision 6729)
+++ trunk/src/lib/graphics/importer/media_container.h	(revision 6731)
@@ -40,9 +40,9 @@
   int video_stream;
   double fps;
+  bool mediaLoaded;
 
 public:
 
-  MediaContainer(const char* filename);
-  MediaContainer();
+  MediaContainer(const char* filename = NULL);
   ~MediaContainer();
 
@@ -55,5 +55,5 @@
   
   GLuint getNextFrame();
-
+  void unloadMedia();
 };
 
Index: trunk/src/lib/graphics/importer/movie_player.cc
===================================================================
--- trunk/src/lib/graphics/importer/movie_player.cc	(revision 6729)
+++ trunk/src/lib/graphics/importer/movie_player.cc	(revision 6731)
@@ -33,22 +33,28 @@
 MoviePlayer::MoviePlayer(const char* filename)
 {
-  this->init();
-
-  if (filename != NULL)
-  {
-    if(!this->loadMovie(filename))
-      PRINTF(1)("MoviePlayer::loadMovie() failes for %s\n", filename);
-  }
-}
-
-MoviePlayer::MoviePlayer()
-{
-  this->init();
-}
+  // set the class id for the base object
+  this->setClassID(CL_MOVIE_PLAYER, "MoviePlayer");
+
+  status = STOP;
+  timer = 0;
+  frame_number = 0;
+
+  mediaLoaded = false;
+
+  this->loadMovie(filename);
+
+}
+
 
 MoviePlayer::~MoviePlayer()
 {
-  //delete material;
-  //delete model;
+  this->unloadMedia();
+}
+
+void MoviePlayer::unloadMedia()
+{
+  // check whether a movie is already loaded
+  if(!mediaLoaded)
+    return;
 
   if (glIsTexture(texture))
@@ -62,6 +68,4 @@
   av_free(frame);
 
-  avcodec_default_free_buffers(codec_context);
-
   // Close the codec
   avcodec_close(codec_context);
@@ -69,30 +73,27 @@
   // Close the video file
   av_close_input_file(format_context);
-}
-
-void MoviePlayer::init()
-{
-  // set the class id for the base object
-  this->setClassID(CL_MOVIE_PLAYER, "MoviePlayer");
 
   status = STOP;
   timer = 0;
   frame_number = 0;
-  loading = false;
-
-  /*material = new Material;
-  material->setDiffuseMap("maps/radialTransparency.png");
-
-  model = new PrimitiveModel(PRIM_PLANE, 10.0);
-
-  LightManager* lightMan = LightManager::getInstance();
-  lightMan->setAmbientColor(.1,.1,.1);
-  (new Light())->setAbsCoor(5.0, 10.0, 40.0);
-  (new Light())->setAbsCoor(-10, -20, -100);
-  */
-}
+
+  mediaLoaded = false;
+
+}
+
 
 bool MoviePlayer::loadMovie(const char* filename)
 {
+  this->unloadMedia();
+
+  if(filename == NULL)
+    return false;
+  // check whether file exists
+  if(!ResourceManager::isInDataDir(filename))
+  {
+    PRINTF(1)("Could not find %s\n", filename);
+    return false;
+  }
+
   // register all formats and codecs
   av_register_all();
@@ -177,5 +178,5 @@
   glBindTexture(GL_TEXTURE_2D, 0);
 
-  loading = true;
+  mediaLoaded = true;
   return true;
 }
@@ -277,5 +278,5 @@
 bool MoviePlayer::gotoFrame(int frames)
 {
-  if(!loading)
+  if(!mediaLoaded)
   {
     PRINTF(0)("Load first the media file with loadMovie\n");
@@ -344,8 +345,4 @@
     status = PLAY;
     timer = 0;
-
-    this->gotoFrame(start_frame);
-
-    PRINTF(0)("start\n");
   }
 }
@@ -354,8 +351,5 @@
 {
   if(status == PAUSE)
-  {
     status = PLAY;
-    PRINTF(0)("resume\n");
-  }
 }
 
@@ -363,8 +357,5 @@
 {
   if(status == PLAY)
-  {
     status = PAUSE;
-    PRINTF(0)("pause\n");
-  }
 }
 
@@ -372,6 +363,4 @@
 {
   status = STOP;
-
-  PRINTF(0)("stop\n");
 }
 
@@ -389,16 +378,6 @@
         this->skipFrame(actual_frame - frame_number - 1);
     }
-    //PRINTF(0)("frame_number: %i\n", frame_number);
-  }
-}
-
-/*const void MoviePlayer::draw()
-{
-  material->select();
-  glBindTexture(GL_TEXTURE_2D, texture);
-  model->draw();
-
-  LightManager::getInstance()->draw();
-}*/
+  }
+}
 
 GLuint MoviePlayer::getTexture()
@@ -425,5 +404,5 @@
 void MoviePlayer::printInformation()
 {
-  if(!loading)
+  if(!mediaLoaded)
   {
     PRINTF(0)("Load first the media file with loadMovie\n");
Index: trunk/src/lib/graphics/importer/movie_player.h
===================================================================
--- trunk/src/lib/graphics/importer/movie_player.h	(revision 6729)
+++ trunk/src/lib/graphics/importer/movie_player.h	(revision 6731)
@@ -17,9 +17,5 @@
 
 #include "glincl.h"
-
-//#include "light.h"
 #include "texture.h"
-//#include "material.h"
-//#include "primitive_model.h"
 
 // include base_object.h since all classes are derived from this one
@@ -29,6 +25,6 @@
 typedef enum MP_STATUS {
   PLAY,
-        PAUSE,
-        STOP
+  PAUSE,
+  STOP
 };
 
@@ -37,7 +33,4 @@
 
 private:
-
-  //Model* model;
-  //Material* material;
 
   AVFormatContext* format_context;
@@ -61,38 +54,35 @@
   float fps;
   int duration;
-  bool loading;
+  bool mediaLoaded;
 
 public:
 
-  MoviePlayer(const char* filename);
-  MoviePlayer();
+  MoviePlayer(const char* filename = NULL);
   ~MoviePlayer();
 
   bool loadMovie(const char* filename);
 
-        void start(float start_time);
-        void resume();
-        void pause();
-        void stop();
+  void start(float start_time);
+  void resume();
+  void pause();
+  void stop();
 
-        void tick(float dt);
-        //const void draw();
-        GLuint getTexture();
+  void tick(float dt);
+  GLuint getTexture();
 
-        void setFPS(float fps);
-        float getFPS();
-        const MP_STATUS getStatus();
+  void setFPS(float fps);
+  float getFPS();
+  const MP_STATUS getStatus();
   void printInformation();
 
 private:
 
-  void init();
   void getNextFrame();
   void skipFrame(int frames);
   bool gotoFrame(int frames);
 
+  void unloadMedia();
+
 };
 
-
-
 #endif // _MOVIE_PLAYER
