Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 25, 2006, 4:18:25 PM (18 years ago)
Author:
hdavid
Message:

branches/avi_play: safe

File:
1 edited

Legend:

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

    r6611 r6711  
    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))
     
    6773  // Close the video file
    6874  av_close_input_file(format_context);
    69 }
    70 
    71 void MoviePlayer::init()
    72 {
    73   // set the class id for the base object
    74   this->setClassID(CL_MOVIE_PLAYER, "MoviePlayer");
    7575
    7676  status = STOP;
    7777  timer = 0;
    7878  frame_number = 0;
    79   loading = false;
    80 }
     79
     80  mediaLoaded = false;
     81
     82}
     83
    8184
    8285bool MoviePlayer::loadMovie(const char* filename)
    8386{
     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
    8498  // register all formats and codecs
    8599  av_register_all();
     
    164178  glBindTexture(GL_TEXTURE_2D, 0);
    165179
    166   loading = true;
     180  mediaLoaded = true;
    167181  return true;
    168182}
     
    264278bool MoviePlayer::gotoFrame(int frames)
    265279{
    266   if(!loading)
     280  if(!mediaLoaded)
    267281  {
    268282    PRINTF(0)("Load first the media file with loadMovie\n");
     
    390404void MoviePlayer::printInformation()
    391405{
    392   if(!loading)
     406  if(!mediaLoaded)
    393407  {
    394408    PRINTF(0)("Load first the media file with loadMovie\n");
Note: See TracChangeset for help on using the changeset viewer.