VideoHandle VideoManager::createVideoHandle(uint16 id, uint16 x, uint16 y, bool loop, byte volume) { // First, check to see if that video is already playing for (uint32 i = 0; i < _videoStreams.size(); i++) if (_videoStreams[i].id == id) return i; // Otherwise, create a new entry Video::QuickTimeDecoder *decoder = new Video::QuickTimeDecoder(); decoder->setChunkBeginOffset(_vm->getResourceOffset(ID_TMOV, id)); decoder->loadStream(_vm->getResource(ID_TMOV, id)); decoder->setVolume(volume); VideoEntry entry; entry.clear(); entry.video = decoder; entry.x = x; entry.y = y; entry.id = id; entry.loop = loop; entry.volume = volume; entry.enabled = true; // Search for any deleted videos so we can take a formerly used slot for (uint32 i = 0; i < _videoStreams.size(); i++) if (!_videoStreams[i].video) { _videoStreams[i] = entry; return i; } // Otherwise, just add it to the list _videoStreams.push_back(entry); return _videoStreams.size() - 1; }
VideoHandle VideoManager::createVideoHandle(const Common::String &filename, uint16 x, uint16 y, bool loop) { // First, check to see if that video is already playing for (uint32 i = 0; i < _videoStreams.size(); i++) if (_videoStreams[i].filename == filename) return i; // Otherwise, create a new entry VideoEntry entry; entry.clear(); entry.video = new Video::QuickTimeDecoder(); entry.x = x; entry.y = y; entry.filename = filename; entry.loop = loop; entry.enabled = true; Common::File *file = new Common::File(); if (!file->open(filename)) { delete file; return NULL_VID_HANDLE; } entry->loadStream(file); // Search for any deleted videos so we can take a formerly used slot for (uint32 i = 0; i < _videoStreams.size(); i++) if (!_videoStreams[i].video) { _videoStreams[i] = entry; return i; } // Otherwise, just add it to the list _videoStreams.push_back(entry); return _videoStreams.size() - 1; }