Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 25, 2006, 6:46:06 PM (20 years ago)
Author:
bensch
Message:

merged avi_play back to the trunk. command https://svn.orxonox.net/orxonox/branches/avi_play . -r6602:HEAD

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/importer/movie_player.cc

    r6600 r6731  
    3333MoviePlayer::MoviePlayer(const char* filename)
    3434{
    35   this->init();
    36 
    37   if (filename != NULL)
    38   {
    39     if(!this->loadMovie(filename))
    40       PRINTF(1)("MoviePlayer::loadMovie() failes for %s\n", filename);
    41   }
    42 }
    43 
    44 MoviePlayer::MoviePlayer()
    45 {
    46   this->init();
    47 }
     35  // set the class id for the base object
     36  this->setClassID(CL_MOVIE_PLAYER, "MoviePlayer");
     37
     38  status = STOP;
     39  timer = 0;
     40  frame_number = 0;
     41
     42  mediaLoaded = false;
     43
     44  this->loadMovie(filename);
     45
     46}
     47
    4848
    4949MoviePlayer::~MoviePlayer()
    5050{
    51   //delete material;
    52   //delete model;
     51  this->unloadMedia();
     52}
     53
     54void MoviePlayer::unloadMedia()
     55{
     56  // check whether a movie is already loaded
     57  if(!mediaLoaded)
     58    return;
    5359
    5460  if (glIsTexture(texture))
     
    6268  av_free(frame);
    6369
    64   avcodec_default_free_buffers(codec_context);
    65 
    6670  // Close the codec
    6771  avcodec_close(codec_context);
     
    6973  // Close the video file
    7074  av_close_input_file(format_context);
    71 }
    72 
    73 void MoviePlayer::init()
    74 {
    75   // set the class id for the base object
    76   this->setClassID(CL_MOVIE_PLAYER, "MoviePlayer");
    7775
    7876  status = STOP;
    7977  timer = 0;
    8078  frame_number = 0;
    81   loading = false;
    82 
    83   /*material = new Material;
    84   material->setDiffuseMap("maps/radialTransparency.png");
    85 
    86   model = new PrimitiveModel(PRIM_PLANE, 10.0);
    87 
    88   LightManager* lightMan = LightManager::getInstance();
    89   lightMan->setAmbientColor(.1,.1,.1);
    90   (new Light())->setAbsCoor(5.0, 10.0, 40.0);
    91   (new Light())->setAbsCoor(-10, -20, -100);
    92   */
    93 }
     79
     80  mediaLoaded = false;
     81
     82}
     83
    9484
    9585bool MoviePlayer::loadMovie(const char* filename)
    9686{
     87  this->unloadMedia();
     88
     89  if(filename == NULL)
     90    return false;
     91  // check whether file exists
     92  if(!ResourceManager::isInDataDir(filename))
     93  {
     94    PRINTF(1)("Could not find %s\n", filename);
     95    return false;
     96  }
     97
    9798  // register all formats and codecs
    9899  av_register_all();
     
    177178  glBindTexture(GL_TEXTURE_2D, 0);
    178179
    179   loading = true;
     180  mediaLoaded = true;
    180181  return true;
    181182}
     
    277278bool MoviePlayer::gotoFrame(int frames)
    278279{
    279   if(!loading)
     280  if(!mediaLoaded)
    280281  {
    281282    PRINTF(0)("Load first the media file with loadMovie\n");
     
    344345    status = PLAY;
    345346    timer = 0;
    346 
    347     this->gotoFrame(start_frame);
    348 
    349     PRINTF(0)("start\n");
    350347  }
    351348}
     
    354351{
    355352  if(status == PAUSE)
    356   {
    357353    status = PLAY;
    358     PRINTF(0)("resume\n");
    359   }
    360354}
    361355
     
    363357{
    364358  if(status == PLAY)
    365   {
    366359    status = PAUSE;
    367     PRINTF(0)("pause\n");
    368   }
    369360}
    370361
     
    372363{
    373364  status = STOP;
    374 
    375   PRINTF(0)("stop\n");
    376365}
    377366
     
    389378        this->skipFrame(actual_frame - frame_number - 1);
    390379    }
    391     //PRINTF(0)("frame_number: %i\n", frame_number);
    392   }
    393 }
    394 
    395 /*const void MoviePlayer::draw()
    396 {
    397   material->select();
    398   glBindTexture(GL_TEXTURE_2D, texture);
    399   model->draw();
    400 
    401   LightManager::getInstance()->draw();
    402 }*/
     380  }
     381}
    403382
    404383GLuint MoviePlayer::getTexture()
     
    425404void MoviePlayer::printInformation()
    426405{
    427   if(!loading)
     406  if(!mediaLoaded)
    428407  {
    429408    PRINTF(0)("Load first the media file with loadMovie\n");
Note: See TracChangeset for help on using the changeset viewer.