Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6711 in orxonox.OLD for branches


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

branches/avi_play: safe

Location:
branches/avi_play/src/lib/graphics/importer
Files:
4 edited

Legend:

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

    r6704 r6711  
    4545}
    4646
    47 MediaContainer::MediaContainer()
    48 {
    49   // set the class id for the base object
    50   this->setClassID(CL_MEDIA_CONTAINER, "MediaContainer");
    51 
    52   fps = 0;
    53   mediaLoaded = false;
    54 }
    55 
    5647/**
    5748 * Default destructor
     
    10596    return false;
    10697  }
    107 
    108 
    10998
    11099  // register all formats and codecs
  • branches/avi_play/src/lib/graphics/importer/media_container.h

    r6704 r6711  
    4444public:
    4545
    46   MediaContainer(const char* filename);
    47   MediaContainer();
     46  MediaContainer(const char* filename = NULL);
    4847  ~MediaContainer();
    4948
  • 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");
  • branches/avi_play/src/lib/graphics/importer/movie_player.h

    r6611 r6711  
    5454  float fps;
    5555  int duration;
    56   bool loading;
     56  bool mediaLoaded;
    5757
    5858public:
    5959
    60   MoviePlayer(const char* filename);
    61   MoviePlayer();
     60  MoviePlayer(const char* filename = NULL);
    6261  ~MoviePlayer();
    6362
     
    7978private:
    8079
    81   void init();
    8280  void getNextFrame();
    8381  void skipFrame(int frames);
    8482  bool gotoFrame(int frames);
    8583
     84  void unloadMedia();
     85
    8686};
    8787
Note: See TracChangeset for help on using the changeset viewer.