Index: branches/avi_play_merge/config.h.in
===================================================================
--- branches/avi_play_merge/config.h.in	(revision 6485)
+++ branches/avi_play_merge/config.h.in	(revision 6486)
@@ -10,4 +10,10 @@
 #undef HAVE_AL_AL_H
 
+/* Define to 1 if you have the <avcodec.h> header file. */
+#undef HAVE_AVCODEC_H
+
+/* Define to 1 if you have the <avformat.h> header file. */
+#undef HAVE_AVFORMAT_H
+
 /* Define to 1 if you have the `bzero' function. */
 #undef HAVE_BZERO
@@ -15,4 +21,10 @@
 /* if we have CURL */
 #undef HAVE_CURL
+
+/* Define to 1 if you have the <ffmpeg/avcodec.h> header file. */
+#undef HAVE_FFMPEG_AVCODEC_H
+
+/* Define to 1 if you have the <ffmpeg/avformat.h> header file. */
+#undef HAVE_FFMPEG_AVFORMAT_H
 
 /* Define to 1 if you have the <GL/glew.h> header file. */
Index: branches/avi_play_merge/configure.ac
===================================================================
--- branches/avi_play_merge/configure.ac	(revision 6485)
+++ branches/avi_play_merge/configure.ac	(revision 6486)
@@ -1,2 +1,3 @@
+
 ##########################################################################
 #   orxonox - the future of 3D-vertical-scrollers                        #
@@ -522,4 +523,41 @@
 AX_CHECK_REQUIRED_HEADER_LIB([vorbis/codec.h], [vorbis], [main],,, [http://www.xiph.org/ogg/vorbis/index.html])
 AX_CHECK_REQUIRED_HEADER_LIB([vorbis/vorbisfile.h], [vorbisfile], [main],,, [http://www.xiph.org/ogg/vorbis/index.html])
+
+#--------#
+# FFmpeg # 
+#--------#
+# checking for FFmpeg-headers
+  AC_CHECK_HEADERS([avformat.h] ,,
+      [AC_CHECK_HEADERS([ffmpeg/avformat.h] ,,AC_MSG_ERROR([cannot find FFmpeg header.])]))
+# checking for ffmpeg-lib
+  AC_CHECK_LIB([avformat], [main], [FOUND_avformat=yes; LIBS="$LIBS -lavformat"])
+     if test x$FOUND_avformat != xyes ; then
+        echo "------------------"
+        echo "avformat library not found."
+        echo "please install the FFmpeg library, which can be found at http://ffmpeg.sourceforge.net"
+        echo "------------------"
+        exit -1
+     fi
+  AC_CHECK_HEADERS([avcodec.h] ,,
+      [AC_CHECK_HEADERS([ffmpeg/avcodec.h] ,,AC_MSG_ERROR([cannot find FFmpeg header.])]))
+  AC_CHECK_LIB([avcodec], [main], [FOUND_avcodec=yes; LIBS="$LIBS -lavcodec"])
+     if test x$FOUND_avcodec != xyes ; then
+        echo "------------------"
+        echo "avcodec library not found."
+        echo "please install the FFmpeg library, which can be found at http://ffmpeg.sourceforge.net"
+        echo "------------------"
+        exit -1
+     fi
+  AC_CHECK_LIB([avutil], [main], [FOUND_avutil=yes; LIBS="$LIBS -lavutil"])
+
+  AC_CHECK_LIB([theora], [main], [FOUND_theora=yes; LIBS="$LIBS -ltheora"])
+
+  AC_CHECK_LIB([dts], [main], [FOUND_dts=yes; LIBS="$LIBS -ldts"])
+
+  AC_CHECK_LIB([gsm], [main], [FOUND_gsm=yes; LIBS="$LIBS -lgsm"])
+
+  AC_CHECK_LIB([dc1394_control], [main], [FOUND_dc1394_control=yes; LIBS="$LIBS -ldc1394_control"])
+
+  AC_CHECK_LIB([vorbisenc], [main], [FOUND_vorbisenc=yes; LIBS="$LIBS -lvorbisenc"])
 
 #---------#
Index: branches/avi_play_merge/src/defs/class_id.h
===================================================================
--- branches/avi_play_merge/src/defs/class_id.h	(revision 6485)
+++ branches/avi_play_merge/src/defs/class_id.h	(revision 6486)
@@ -226,4 +226,7 @@
   CL_TEXTURE_SEQUENCE           =    0x00004805,
   CL_OBJ_MODEL                  =    0x00000807,
+  
+  CL_MOVIE_PLAYER               =    0x00000805,
+  CL_MEDIA_CONTAINER            =    0x00000806,
   CL_PROMITIVE_MODEL            =    0x00000808,
   CL_MD2Model                   =    0x00000809,
Index: branches/avi_play_merge/src/lib/graphics/importer/Makefile.am
===================================================================
--- branches/avi_play_merge/src/lib/graphics/importer/Makefile.am	(revision 6485)
+++ branches/avi_play_merge/src/lib/graphics/importer/Makefile.am	(revision 6486)
@@ -14,5 +14,7 @@
                            texture.cc \
                            texture_sequence.cc \
-                           height_map.cc
+                           height_map.cc \
+                           media_container.cc \
+                           movie_player.cc
 
 libtc_a_SOURCES  = tc.cc
@@ -32,3 +34,5 @@
                  height_map.h \
                  anorms.h \
-                 anormtab.h
+                 anormtab.h \
+                 media_container.h \
+                 movie_player.h
Index: branches/avi_play_merge/src/lib/graphics/importer/media_container.cc
===================================================================
--- branches/avi_play_merge/src/lib/graphics/importer/media_container.cc	(revision 6486)
+++ branches/avi_play_merge/src/lib/graphics/importer/media_container.cc	(revision 6486)
@@ -0,0 +1,243 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+### File Specific:
+   main-programmer: David Hasenfratz, Stephan Lienhard
+   co-programmer:
+*/
+
+
+
+/* this is for debug output. It just says, that all calls to PRINT() belong to the DEBUG_MODULE_MEDIA module
+   For more information refere to https://www.orxonox.net/cgi-bin/trac.cgi/wiki/DebugOutput
+*/
+#define DEBUG_MODULE_MEDIA
+
+
+/* include your own header */
+#include "media_container.h"
+
+/* header for debug output */
+#include "debug.h"
+
+
+/**
+ * Default constructor
+ */
+MediaContainer::MediaContainer(const char* filename)
+{
+  // set the class id for the base object
+  this->setClassID(CL_MEDIA_CONTAINER, "MediaContainer");
+
+  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;
+}
+
+/**
+ * Default destructor
+ */
+MediaContainer::~MediaContainer()
+{
+  if (glIsTexture(texture))
+    glDeleteTextures(1, &texture);
+
+  // Free the RGB image
+  delete [] buffer;
+  av_free(RGB_frame);
+
+  // Free the frame
+  av_free(frame);
+
+  // Close the codec
+  avcodec_close(codec_context);
+
+  // Close the video file
+  av_close_input_file(format_context);
+}
+
+bool MediaContainer::loadMedia(const char* filename)
+{
+  // register all formats and codecs
+  av_register_all();
+
+  // Open video file
+  if (av_open_input_file(&format_context, filename, NULL, 0, NULL) !=0 )
+  {
+    PRINTF(1)("Could not open %s\n", filename);
+    return false;
+  }
+
+  // Retrieve stream information
+  if (av_find_stream_info(format_context) < 0)
+  {
+    PRINTF(1)("Could not find stream information in %s\n", filename);
+    return false;
+  }
+
+  // Find the first video stream and take it
+  video_stream = av_find_default_stream_index(format_context);
+  
+  if(video_stream == -1)
+  {
+    PRINTF(1)("Could not find a video stream in %s\n", filename);
+    return false;
+  }
+
+  // Get a pointer to the codec context for the video stream
+  // NOTE: different code for the 0.4.9-pre1 release of ffmpeg (tardis)
+  // codec_context = &format_context->streams[video_stream]->codec;
+  codec_context = format_context->streams[video_stream]->codec;
+
+  // Find the decoder for the video stream
+  codec = avcodec_find_decoder(codec_context->codec_id);
+  if (codec == NULL)
+  {
+    PRINTF(1)("Could not find codec\n");
+    return false;
+  }
+
+  // Open codec
+  if (avcodec_open(codec_context, codec) < 0)
+  {
+    PRINTF(1)("Could not open codec\n");
+    return false;
+  }
+
+  // Allocate video frame
+  frame = avcodec_alloc_frame();
+  RGB_frame = avcodec_alloc_frame();
+
+  // Determine required buffer size and allocate buffer
+  num_bytes = avpicture_get_size(PIX_FMT_RGB24, codec_context->width, codec_context->height);
+  buffer=new uint8_t[num_bytes];
+
+  // data buffer for the texture
+  data = new uint8_t[codec_context->width*codec_context->height*3*sizeof(uint8_t)];
+
+  // Assign appropriate parts of buffer to image planes in RGB_frame
+  avpicture_fill((AVPicture *)RGB_frame, buffer, PIX_FMT_RGB24, codec_context->width, codec_context->height);
+
+  // Calculate fps
+  fps = av_q2d(format_context->streams[video_stream]->r_frame_rate);
+  // NOTE: fix this fps problem!!
+  if(fps < 0 || fps > 1000)
+    fps = 30;
+
+  // read the frames and save them in a sequence as textures
+  this->loadFrames();
+
+  return true;
+}
+
+double MediaContainer::getFPS()
+{
+  return this->fps;
+}
+
+void MediaContainer::loadFrames()
+{
+  // empty texture list
+  this->clearLists();
+
+  // go to the begin of the video
+  av_seek_frame(format_context, video_stream, 0, AVSEEK_FLAG_BACKWARD);
+
+  // get all the frames and save them in the sequence
+  while(this->addFrame(this->getNextFrame()) != NULL);
+}
+
+
+GLuint MediaContainer::getNextFrame()
+{
+
+  // get next frame
+  if(av_read_frame(format_context, &packet) >= 0)
+  {
+    // Is this a packet from the video stream?
+    if(packet.stream_index == video_stream)
+    {
+      int frame_finished;
+      // Decode video frame
+      avcodec_decode_video(codec_context, frame, &frame_finished,
+                           packet.data, packet.size);
+
+      // Free the packet that was allocated by av_read_frame
+      av_free_packet(&packet);
+      
+      // Did we get a video frame?
+      if(frame_finished)
+      {
+        // Conversion from YUV to RGB
+        // Most codecs return images in YUV 420 format
+        // (one luminance and two chrominance channels, with the chrominance
+        // channels samples at half the spatial resolution of the luminance channel)
+        img_convert((AVPicture*)RGB_frame, PIX_FMT_RGB24, (AVPicture*)frame,
+                    codec_context->pix_fmt, codec_context->width, codec_context->height);
+
+        for(int i = 0; i < codec_context->height; i++)
+          memcpy(&data[i*codec_context->width*3],
+                 ((AVPicture*)RGB_frame)->data[0]+i *
+                 ((AVPicture*)RGB_frame)->linesize[0], 
+                  codec_context->width*sizeof(uint8_t)*3);
+
+        // Create an OpenGL texture
+        glGenTextures(1, &texture);
+        glBindTexture(GL_TEXTURE_2D, texture);
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+        // create the texture
+        glTexImage2D(GL_TEXTURE_2D,
+                    0,
+                    GL_RGB,
+                    codec_context->width, codec_context->height,
+                    0,
+                    GL_RGB,
+                    GL_UNSIGNED_BYTE,
+                    data);
+        // build the MipMaps
+        gluBuild2DMipmaps(GL_TEXTURE_2D,
+                        GL_RGB,
+                        codec_context->width,
+                        codec_context->height,
+                        GL_RGB,
+                        GL_UNSIGNED_BYTE,
+                        data);
+        glBindTexture(GL_TEXTURE_2D, 0);
+
+        return texture;
+      }
+      else
+      {
+        av_free_packet(&packet);
+        return this->getNextFrame();
+      }
+    }
+    else
+    {
+      av_free_packet(&packet);
+      return this->getNextFrame();
+    }
+  }
+  else
+    return NULL;
+}
Index: branches/avi_play_merge/src/lib/graphics/importer/media_container.h
===================================================================
--- branches/avi_play_merge/src/lib/graphics/importer/media_container.h	(revision 6486)
+++ branches/avi_play_merge/src/lib/graphics/importer/media_container.h	(revision 6486)
@@ -0,0 +1,61 @@
+/*!
+ * @file media_container.h
+  *  Manages the media files
+
+*/
+
+#ifndef _MEDIA_CONTAINER
+#define _MEDIA_CONTAINER
+
+#include <SDL.h>
+
+#ifdef HAVE_AVFORMAT_H
+  #include <avformat.h>
+#else
+  #include <ffmpeg/avformat.h>
+#endif
+
+/* include base_object.h since all classes are derived from this one */
+#include "base_object.h"
+#include "texture_sequence.h"
+
+#include "glincl.h"
+
+class MediaContainer : public TextureSequence
+{
+
+private:
+
+  AVFormatContext* format_context;
+  AVCodecContext* codec_context;
+  AVCodec* codec;
+  AVFrame* frame;
+  AVPacket packet;
+  AVFrame* RGB_frame;
+
+  GLuint texture;
+  uint8_t* data;
+  uint8_t* buffer;
+  int num_bytes;
+  int video_stream;
+  double fps;
+
+public:
+
+  MediaContainer(const char* filename);
+  MediaContainer();
+  ~MediaContainer();
+
+  bool loadMedia(const char* filename);
+  void loadFrames();
+
+  double getFPS();
+
+private:
+  
+  GLuint getNextFrame();
+
+};
+
+
+#endif /* _MEDIA_CONTAINER */
Index: branches/avi_play_merge/src/lib/graphics/importer/movie_player.cc
===================================================================
--- branches/avi_play_merge/src/lib/graphics/importer/movie_player.cc	(revision 6486)
+++ branches/avi_play_merge/src/lib/graphics/importer/movie_player.cc	(revision 6486)
@@ -0,0 +1,455 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+### File Specific:
+   main-programmer: David Hasenfratz
+   co-programmer:
+*/
+
+
+
+/* this is for debug output. It just says, that all calls to PRINT() belong to the DEBUG_MODULE_MEDIA module
+   For more information refere to https://www.orxonox.net/cgi-bin/trac.cgi/wiki/DebugOutput
+*/
+#define DEBUG_MODULE_MEDIA
+
+
+// include your own header
+#include "movie_player.h"
+
+// header for debug output
+#include "debug.h"
+
+
+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();
+}
+
+MoviePlayer::~MoviePlayer()
+{
+  delete material;
+  delete model;
+
+  if (glIsTexture(texture))
+    glDeleteTextures(1, &texture);
+
+  // Free the RGB image
+  delete [] buffer;
+  av_free(RGB_frame);
+
+  // Free the frame
+  av_free(frame);
+
+  avcodec_default_free_buffers(codec_context);
+
+  // Close the codec
+  avcodec_close(codec_context);
+
+  // 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);
+}
+
+bool MoviePlayer::loadMovie(const char* filename)
+{
+  // register all formats and codecs
+  av_register_all();
+
+  // Open video file
+  if (av_open_input_file(&format_context, filename, NULL, 0, NULL) !=0 )
+  {
+    PRINTF(1)("Could not open %s\n", filename);
+    return false;
+  }
+
+  // Retrieve stream information
+  if (av_find_stream_info(format_context) < 0)
+  {
+    PRINTF(1)("Could not find stream information in %s\n", filename);
+    return false;
+  }
+
+  // Find the first video stream and take it
+  video_stream = av_find_default_stream_index(format_context);
+
+  if(video_stream == -1)
+  {
+    PRINTF(1)("Could not find a video stream in %s\n", filename);
+    return false;
+  }
+
+  // Get a pointer to the codec context for the video stream
+  // NOTE: different code for the 0.4.9-pre1 release of ffmpeg (tardis)
+  // codec_context = &format_context->streams[video_stream]->codec;
+  codec_context = format_context->streams[video_stream]->codec;
+
+  // Find the decoder for the video stream
+  codec = avcodec_find_decoder(codec_context->codec_id);
+  if (codec == NULL)
+  {
+    PRINTF(1)("Could not find codec\n");
+    return false;
+  }
+
+  // Open codec
+  if (avcodec_open(codec_context, codec) < 0)
+  {
+    PRINTF(1)("Could not open codec\n");
+    return false;
+  }
+
+  // Allocate video frame
+  frame = avcodec_alloc_frame();
+  RGB_frame = avcodec_alloc_frame();
+
+  // Determine required buffer size and allocate buffer
+  num_bytes = avpicture_get_size(PIX_FMT_RGB24, codec_context->width, codec_context->height);
+  buffer=new uint8_t[num_bytes];
+
+  // Assign appropriate parts of buffer to image planes in RGB_frame
+  avpicture_fill((AVPicture *)RGB_frame, buffer, PIX_FMT_RGB24, codec_context->width, codec_context->height);
+
+  // data buffer for the texture
+  data = new uint8_t[codec_context->width*codec_context->height*3*sizeof(uint8_t)];
+
+  // Calculate fps
+  fps = av_q2d(format_context->streams[video_stream]->r_frame_rate);
+  // NOTE: fix this fps problem!!
+  if(fps < 0 || fps > 1000)
+    fps = 30;
+
+  // duration
+  duration = format_context->duration / 1000000LL;
+
+  // create texture
+  glGenTextures(1, &texture);
+  glBindTexture(GL_TEXTURE_2D, texture);
+  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+  glTexImage2D(GL_TEXTURE_2D,
+              0,
+              GL_RGB,
+              0, 0,
+              0,
+              GL_RGB,
+              GL_UNSIGNED_BYTE,
+              NULL);
+  glBindTexture(GL_TEXTURE_2D, 0);
+
+  loading = true;
+  return true;
+}
+
+void MoviePlayer::getNextFrame()
+{
+  // get next frame
+  if(av_read_frame(format_context, &packet) >= 0)
+  {
+    // Is this a packet from the video stream?
+    if(packet.stream_index == video_stream)
+    {
+      int frame_finished;
+      // Decode video frame
+      avcodec_decode_video(codec_context, frame, &frame_finished,
+                           packet.data, packet.size);
+
+      // Free the packet that was allocated by av_read_frame
+      av_free_packet(&packet);
+      
+      // Did we get a video frame?
+      if(frame_finished)
+      {
+        frame_number++;
+        //PRINTF(0)("frame_number: %i\n", frame_number);
+        // Conversion from YUV to RGB
+        // Most codecs return images in YUV 420 format
+        // (one luminance and two chrominance channels, with the chrominance
+        // channels samples at half the spatial resolution of the luminance channel)
+        img_convert((AVPicture*)RGB_frame, PIX_FMT_RGB24, (AVPicture*)frame,
+                    codec_context->pix_fmt, codec_context->width, codec_context->height);
+
+        for(int i = 0; i < codec_context->height; i++)
+          memcpy(&data[i*codec_context->width*3], ((AVPicture*)RGB_frame)->data[0]+i *
+                 ((AVPicture*)RGB_frame)->linesize[0],
+                 codec_context->width*sizeof(uint8_t)*3);
+
+        glBindTexture(GL_TEXTURE_2D, texture);
+        // update the texture
+        glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,
+                          codec_context->width, codec_context->height,
+                          GL_RGB, GL_UNSIGNED_BYTE,
+                          data);
+        // build the MipMaps
+        gluBuild2DMipmaps(GL_TEXTURE_2D,
+                        GL_RGB,
+                        codec_context->width,
+                        codec_context->height,
+                        GL_RGB,
+                        GL_UNSIGNED_BYTE,
+                        data);
+        glBindTexture(GL_TEXTURE_2D, 0);
+
+      }
+      else
+      {
+        av_free_packet(&packet);
+        this->getNextFrame();
+      }
+    }
+    else
+    {
+      av_free_packet(&packet);
+      this->getNextFrame();
+    }
+  }
+  else
+    this->stop();
+}
+
+void MoviePlayer::skipFrame(int frames)
+{
+  
+  while(frames != 0)
+  {
+    if(av_read_frame(format_context, &packet) < 0)
+      break;
+    if(packet.stream_index == video_stream)
+    {
+      int frame_finished;
+      // We have to decode the frame to not get ugly fragments
+      avcodec_decode_video(codec_context, frame, &frame_finished,
+                            packet.data, packet.size);
+        
+      // Did we get a video frame?
+      if(frame_finished)
+      {
+        frames--;
+        frame_number++;
+      }
+    }
+    av_free_packet(&packet);
+  }
+  
+  this->getNextFrame();
+
+}
+
+bool MoviePlayer::gotoFrame(int frames)
+{
+  if(!loading)
+  {
+    PRINTF(0)("Load first the media file with loadMovie\n");
+    return false;
+  }
+
+  int err;
+  // seek doesnt work for the first two frames
+  // you will get ugly fragments
+  if(frames < 2)
+  {
+    // go to the begin of the video
+    err = av_seek_frame(format_context, video_stream, 0, AVSEEK_FLAG_BACKWARD);
+    if(err < 0)
+    {
+      PRINTF(1)("Could not seek to frame 0\n");
+      return false;
+    }
+
+    this->frame_number = 0;
+  }
+  else
+  {
+    // seeks to the nearest keyframe
+    // NOTE: there is only about every 5s a keyframe!
+    err = av_seek_frame(format_context, video_stream, frames, AVSEEK_FLAG_BACKWARD);
+    if(err < 0)
+    {
+      PRINTF(1)("Could not seek to frame %i\n", frames);
+      return false;
+    }
+    
+    // go from the keyframe to the exact position
+    codec_context->hurry_up = 1;
+    do {
+      if(av_read_frame(format_context, &packet) < 0)
+      {
+        PRINTF(1)("Could not seek to frame %i\n", frames);
+        return false;
+      }
+
+      if(packet.stream_index == video_stream)
+      {
+        if(packet.pts >= frames-1)
+          break;
+        int frame_finished;
+        avcodec_decode_video(codec_context, frame, &frame_finished, packet.data, packet.size);
+        av_free_packet(&packet);
+      }
+    } while(1);
+    codec_context->hurry_up = 0;
+  
+    this->frame_number = frames;
+  }
+  
+  return true;
+}
+
+void MoviePlayer::start(float start_time)
+{
+  //start_frame = start_time * fps;
+  start_frame = 0;
+
+  if(this->gotoFrame(start_frame))
+  {
+    status = PLAY;
+    timer = 0;
+  
+    this->gotoFrame(start_frame);
+  
+    PRINTF(0)("start\n");
+  }
+}
+
+void MoviePlayer::resume()
+{
+  if(status == PAUSE)
+  {
+    status = PLAY;
+    PRINTF(0)("resume\n");
+  }
+}
+
+void MoviePlayer::pause()
+{
+  if(status == PLAY)
+  {
+    status = PAUSE;
+    PRINTF(0)("pause\n");
+  }
+}
+
+void MoviePlayer::stop()
+{
+  status = STOP;
+
+  PRINTF(0)("stop\n");
+}
+
+void MoviePlayer::tick(float dt)
+{
+  if(status == PLAY)
+  {
+    timer += dt;
+    actual_frame = timer * fps + start_frame;
+    if(actual_frame != frame_number)
+    {
+      if(actual_frame - frame_number == 1)
+        this->getNextFrame();
+      else
+        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();
+}
+
+void MoviePlayer::setFPS(float fps)
+{
+  if(fps > 0)
+    this->fps = fps;
+}
+
+float MoviePlayer::getFPS()
+{
+  return this->fps;
+}
+
+const MP_STATUS MoviePlayer::getStatus()
+{
+  return this->status;
+}
+
+void MoviePlayer::printInformation()
+{
+  if(!loading)
+  {
+    PRINTF(0)("Load first the media file with loadMovie\n");
+    return;
+  }
+
+  PRINTF(0)("========================\n");
+  PRINTF(0)("========================\n");
+  PRINTF(0)("=    MEDIACONTAINER    =\n");
+  PRINTF(0)("========================\n");
+  PRINTF(0)("========================\n");
+  PRINTF(0)("=    AVFormatContext   =\n");
+  PRINTF(0)("========================\n");
+  PRINTF(0)("filename: %s\n", format_context->filename);
+  PRINTF(0)("nb_streams: %i\n", format_context->nb_streams);
+  PRINTF(0)("duration: (%02d:%02d:%02d)\n", duration/3600, (duration%3600)/60, duration%60);
+  PRINTF(0)("file_size: %ikb\n", format_context->file_size/1024);
+  PRINTF(0)("bit_rate: %ikb/s\n", format_context->bit_rate/1000);
+  PRINTF(0)("nb_frames: %i\n", format_context->streams[video_stream]->nb_frames);
+  PRINTF(0)("r_frame_rate: %i\n", format_context->streams[video_stream]->r_frame_rate.num);
+  PRINTF(0)("fps: %0.2f\n", fps);
+  PRINTF(0)("========================\n");
+  PRINTF(0)("=    AVCodecContext    =\n");
+  PRINTF(0)("========================\n");
+  PRINTF(0)("width: %i\n", codec_context->width);
+  PRINTF(0)("height: %i\n", codec_context->height);
+  PRINTF(0)("time_base.den: %i\n", codec_context->time_base.den);
+  PRINTF(0)("time_base.num: %i\n", codec_context->time_base.num);
+  PRINTF(0)("========================\n");
+  PRINTF(0)("=       AVCodec        =\n");
+  PRINTF(0)("========================\n");
+  PRINTF(0)("codec name: %s\n", codec->name);
+  PRINTF(0)("========================\n");
+  PRINTF(0)("========================\n");
+}
Index: branches/avi_play_merge/src/lib/graphics/importer/movie_player.h
===================================================================
--- branches/avi_play_merge/src/lib/graphics/importer/movie_player.h	(revision 6486)
+++ branches/avi_play_merge/src/lib/graphics/importer/movie_player.h	(revision 6486)
@@ -0,0 +1,97 @@
+/*!
+ * @file movie_player.h
+  *  Manages the media files
+
+*/
+
+#ifndef _MOVIE_PLAYER
+#define _MOVIE_PLAYER
+
+#include <SDL.h>
+
+#ifdef HAVE_AVFORMAT_H
+  #include <avformat.h>
+#else
+  #include <ffmpeg/avformat.h>
+#endif
+
+#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
+#include "base_object.h"
+
+// The state of the MoviePlayer
+typedef enum MP_STATUS {
+  PLAY,
+	PAUSE,
+	STOP
+};
+
+class MoviePlayer : public BaseObject
+{
+
+private:
+
+  Model* model;
+  Material* material;
+
+  AVFormatContext* format_context;
+  AVCodecContext* codec_context;
+  AVCodec* codec;
+  AVFrame* frame;
+  AVPacket packet;
+  AVFrame* RGB_frame;
+
+  GLuint texture;
+  uint8_t* data;
+  uint8_t* buffer;
+  int num_bytes;
+  int video_stream;
+
+  MP_STATUS status;	
+  float timer;
+  int start_frame;
+  int actual_frame;
+  int frame_number;
+  float fps;
+  int duration;
+  bool loading;  
+
+public:
+
+  MoviePlayer(const char* filename);
+  MoviePlayer();
+  ~MoviePlayer();
+
+  bool loadMovie(const char* filename);
+
+	void start(float start_time);
+	void resume();
+	void pause();
+	void stop();
+
+	void tick(float dt);
+	const void draw();
+
+	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);
+
+};
+
+
+
+#endif // _MOVIE_PLAYER
Index: branches/avi_play_merge/src/lib/graphics/importer/texture.cc
===================================================================
--- branches/avi_play_merge/src/lib/graphics/importer/texture.cc	(revision 6485)
+++ branches/avi_play_merge/src/lib/graphics/importer/texture.cc	(revision 6486)
@@ -199,5 +199,5 @@
                                0xFF000000
 #else
-                                   0xFF000000,
+                               0xFF000000,
                                0x00FF0000,
                                0x0000FF00,
Index: branches/avi_play_merge/src/lib/graphics/importer/texture_sequence.cc
===================================================================
--- branches/avi_play_merge/src/lib/graphics/importer/texture_sequence.cc	(revision 6485)
+++ branches/avi_play_merge/src/lib/graphics/importer/texture_sequence.cc	(revision 6486)
@@ -47,4 +47,9 @@
 TextureSequence::~TextureSequence()
 {
+  this->clearLists();
+}
+
+void TextureSequence::clearLists()
+{
   // delete all images
   while(!this->images.empty())
@@ -54,5 +59,4 @@
   }
 
-  this->setTexture(0);
   // delete all textures.
   while(!this->textures.empty())
@@ -63,5 +67,4 @@
   }
 }
-
 
 /**
@@ -149,8 +152,20 @@
   }
   this->setAlpha(hasAlpha);
+
   return true;
 }
 
+/**
+ * @brief adds a new Frame at the end of the Sequence.
+ * @param texture the texture to add at the end of the Sequence.
+ */
+bool TextureSequence::addFrame(GLuint texture)
+{
+  if (texture == 0)
+    return false;
+  this->textures.push_back(texture);
 
+  return true;
+}
 
 /**
@@ -158,7 +173,8 @@
  * @param frameNumber the n-th frame
  */
-void TextureSequence::gotoFrame(unsigned int frameNumber)
+/*void TextureSequence::gotoFrame(unsigned int frameNumber)
 {
   if (this->textures.size() > frameNumber)
     this->setTexture(this->textures[frameNumber]);
 }
+*/
Index: branches/avi_play_merge/src/lib/graphics/importer/texture_sequence.h
===================================================================
--- branches/avi_play_merge/src/lib/graphics/importer/texture_sequence.h	(revision 6485)
+++ branches/avi_play_merge/src/lib/graphics/importer/texture_sequence.h	(revision 6486)
@@ -29,4 +29,7 @@
     bool addFrame(const char* image);
     bool addFrame(SDL_Surface* surface);
+    bool addFrame(GLuint texture);
+
+    void clearLists();
 
     virtual bool rebuild();
@@ -35,5 +38,5 @@
     inline unsigned int getFrameCount() const { return this->textures.size(); };
 
-    void gotoFrame(unsigned int frameNumber);
+    //void gotoFrame(unsigned int frameNumber);
     /** @returns The textureID of the Frame @param frameNumber the n-th frame this texture-series.  */
     inline GLuint getFrameTexture(unsigned int frameNumber) const { return (this->textures.size()>frameNumber)?this->textures[frameNumber]:0; };
Index: branches/avi_play_merge/src/subprojects/importer/Makefile.am
===================================================================
--- branches/avi_play_merge/src/subprojects/importer/Makefile.am	(revision 6485)
+++ branches/avi_play_merge/src/subprojects/importer/Makefile.am	(revision 6486)
@@ -7,5 +7,6 @@
 
 bin_PROGRAMS = importer \
-               multitex
+               multitex \
+							 movie_player_test
 
 importer_LDADD = $(MAINSRCDIR)/lib/event/libORXevent.a \
@@ -63,2 +64,29 @@
                   $(MAINSRCDIR)/lib/util/executor/executor.cc \
                   $(MAINSRCDIR)/util/loading/factory.cc
+
+movie_player_test_LDADD = $(MAINSRCDIR)/lib/event/libORXevent.a \
+                 					$(MAINSRCDIR)/lib/parser/tinyxml/libtinyxml.a \
+                 					$(MAINSRCDIR)/lib/graphics/libORXgraphics.a \
+                 					$(MAINSRCDIR)/lib/shell/libORXshell.a \
+                 					$(MAINSRCDIR)/lib/sound/libORXsound.a \
+                 					$(MAINSRCDIR)/lib/graphics/importer/libORXimporter.a
+
+movie_player_test_SOURCES= ../framework.cc \
+                  				 movie_player_test.cc \
+                  				 $(MAINSRCDIR)/util/state.cc \
+                  				 $(MAINSRCDIR)/world_entities/camera.cc \
+                  				 $(MAINSRCDIR)/lib/lang/base_object.cc \
+													 $(MAINSRCDIR)/lib/lang/class_list.cc \
+													 $(MAINSRCDIR)/lib/math/vector.cc \
+													 $(MAINSRCDIR)/util/loading/resource_manager.cc \
+													 $(MAINSRCDIR)/lib/parser/ini_parser/ini_parser.cc \
+													 $(MAINSRCDIR)/lib/coord/p_node.cc \
+													 $(MAINSRCDIR)/lib/coord/null_parent.cc \
+													 $(MAINSRCDIR)/util/loading/load_param.cc \
+													 $(MAINSRCDIR)/util/loading/load_param_description.cc \
+													 $(MAINSRCDIR)/lib/util/helper_functions.cc \
+													 $(MAINSRCDIR)/lib/util/substring.cc \
+													 $(MAINSRCDIR)/lib/util/color.cc \
+													 $(MAINSRCDIR)/lib/util/multi_type.cc \
+													 $(MAINSRCDIR)/lib/util/executor/executor.cc \
+													 $(MAINSRCDIR)/util/loading/factory.cc
Index: branches/avi_play_merge/src/subprojects/importer/movie_player_test.cc
===================================================================
--- branches/avi_play_merge/src/subprojects/importer/movie_player_test.cc	(revision 6486)
+++ branches/avi_play_merge/src/subprojects/importer/movie_player_test.cc	(revision 6486)
@@ -0,0 +1,85 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: David Hasenfratz
+   co-programmer: ...
+
+   this file extends the framework file, so it renders what i want.
+*/
+
+#include <stdlib.h>
+
+#include "framework.h"
+#include "movie_player.h"
+
+MoviePlayer* movie_player;
+
+void Framework::moduleInit(int argc, char** argv)
+{
+  if( argc <= 1)
+  {
+    printf("Wrong arguments try following notations:\n");
+    printf("./movie_player_test [media_file]\n");
+    exit(0);
+  }
+
+  movie_player = new MoviePlayer(argv[1]);
+
+  
+  movie_player->printInformation();
+}
+
+void Framework::moduleEventHandler(SDL_Event* event)
+{
+  switch (event->type)
+  {
+    case SDL_KEYDOWN:
+      switch (event->key.keysym.sym)
+      {
+        case SDLK_1:
+          movie_player->start(0);
+          break;
+        case SDLK_2:
+          movie_player->resume();
+          break;
+        case SDLK_3:
+          movie_player->pause();
+          break;
+        case SDLK_4:
+          movie_player->stop();
+          break;
+        case SDLK_9:
+          movie_player->setFPS(movie_player->getFPS() - 1);
+          PRINTF(0)("fps: %0.2f\n", movie_player->getFPS());
+          break;
+        case SDLK_0:
+          movie_player->setFPS(movie_player->getFPS() + 1);
+          PRINTF(0)("fps: %0.2f\n", movie_player->getFPS());
+          break;
+      }
+  }
+}
+
+void Framework::moduleTick(float dt)
+{
+  movie_player->tick(dt);
+}
+
+void Framework::moduleDraw(void) const
+{
+  movie_player->draw();
+}
+
+
+void Framework::moduleHelp(void) const
+{
+
+}
Index: branches/avi_play_merge/src/subprojects/importer/multitex.cc
===================================================================
--- branches/avi_play_merge/src/subprojects/importer/multitex.cc	(revision 6485)
+++ branches/avi_play_merge/src/subprojects/importer/multitex.cc	(revision 6486)
@@ -10,5 +10,5 @@
 
    ### File Specific:
-   main-programmer: Benjamin Grauer
+   main-programmer: David Hasenfratz
    co-programmer: ...
 
@@ -20,43 +20,33 @@
 #include "light.h"
 
-#include "texture_sequence.h"
 #include "material.h"
-
-#include "objModel.h"
-
 #include "primitive_model.h"
 #include <stdlib.h>
 
-#include "resource_manager.h"
+#include "media_container.h"
 
 Model* obj;
-TextureSequence* seq;
-Texture* test;
 Material* testMat;
+MediaContainer* media_container;
 
-float counter = 0;
+int counter = 0;
+float timer = 0;
+float fps;
 
 
 void Framework::moduleInit(int argc, char** argv)
 {
-  ResourceManager::getInstance()->addImageDir("./");
+  if( argc <= 1)
+  {
+    printf("Wrong arguments try following notations:\n");
+    printf("./multitex [media_file]\n");
+    exit(0);
+  }
+
+  media_container = new MediaContainer(argv[1]);
 
   testMat = new Material;
-
-  seq = new TextureSequence();
-  for (int i = 1; i < argc; i++)
-  {
-    seq->addFrame(argv[i]);
-    printf("%s\n", argv[i]);
-  }
-  test = new Texture(argv[1]);
-  testMat->setDiffuseMap(argv[1]);
-
-  ResourceManager::getInstance()->addImageDir("");
-
-
-  obj = new PrimitiveModel(PRIM_SPHERE, 10.0);
-
-  ResourceManager::getInstance()->debug();
+  testMat->setDiffuseMap("maps/radialTransparency.png");
+  obj = new PrimitiveModel(PRIM_PLANE, 10.0);
 
   LightManager* lightMan = LightManager::getInstance();
@@ -64,4 +54,6 @@
   (new Light())->setAbsCoor(5.0, 10.0, 40.0);
   (new Light())->setAbsCoor(-10, -20, -100);
+
+  fps = media_container->getFPS();
 }
 
@@ -73,5 +65,23 @@
       switch (event->key.keysym.sym)
         {
-        case SDLK_i:
+        case SDLK_1:
+          obj = new PrimitiveModel(PRIM_CUBE, 10.0);
+          break;
+        case SDLK_2:
+          obj = new PrimitiveModel(PRIM_SPHERE, 10.0);
+          break;
+        case SDLK_3:
+          obj = new PrimitiveModel(PRIM_PLANE, 10.0);
+          break;
+        // increase fps
+        case SDLK_9:
+          fps++;
+          PRINTF(0)("fps: %0.2f\n", fps);
+          break;
+        // decrease fps
+        case SDLK_8:
+          if(fps > 0)
+            fps--;
+          PRINTF(0)("fps: %0.2f\n", fps);
           break;
         }
@@ -81,9 +91,16 @@
 void Framework::moduleTick(float dt)
 {
-  counter+=dt;
+  timer += dt;
 
-  seq->gotoFrame((unsigned int)counter);
-  if ((unsigned int)counter > seq->getFrameCount())
-    counter = 0;
+  if(counter != fps * timer)
+  {
+    counter = fps * timer;
+
+    if (counter >= media_container->getFrameCount())
+    {
+      timer = 0;
+      counter = 0;
+    }
+  }
 }
 
@@ -91,5 +108,5 @@
 {
   testMat->select();
-  glBindTexture(GL_TEXTURE_2D, seq->getTexture());
+  glBindTexture(GL_TEXTURE_2D, media_container->getFrameTexture(counter));
   obj->draw();
 
@@ -97,5 +114,4 @@
 }
 
-
 void Framework::moduleHelp(void) const
 {
