コード例 #1
0
void VideoManager::loadVideo(char* filename)
{
	FILE* fp = NULL;
	if ( fopen_s(&fp, filename, "rb") != 0 )
	{
		al_trace("Movie %s is missing.\r\n", filename);
		return; // do NOT summon error mode for this because the application might in debugging/lite mode
	}

	// get the length of the video
	fseek(fp, 0, SEEK_END);
    long fsize = ftell(fp);
	fseek(fp, 0, SEEK_SET);
	
	// load the entire video into an unreasonably large memory buffer!
	videoBuffer = malloc(fsize);
	fread(videoBuffer, fsize, 1, fp);
	fclose(fp);

	// sanity check the buffer contents or else APEG may hang
	if ( ((char*)videoBuffer)[0] == 'O' && ((char*)videoBuffer)[1] == 'g' && ((char*)videoBuffer)[2] == 'g' && ((char*)videoBuffer)[3] == 'S' )
	{
		cmov = apeg_open_memory_stream(videoBuffer, fsize);
	}
	else
	{
		al_trace("Video stream did not seem to contain Ogg data.\r\n");
		unloadVideo();
	}
}
コード例 #2
0
void VideoManager::loadVideoAtCurrentStep()
{
	char filename[256] = "DATA/video/";
	if ( script[currentStep].filename[0] == '*' )
	{
		strcat_s(filename, 256, script[currentStep-1].filename); // check for videos named '*'. I think the original game used this to denote "play that video again"
	}
	else
	{
		strcat_s(filename, 256, script[currentStep].filename);
	}
	strcat_s(filename, 256, ".ogg");

	// default case: show a placeholder texture
	unloadVideo();
	clear_to_color(frameData, makecol(255,255,255));
	textprintf_centre(frameData, font, 160, 90, makecol(0,0,0), "%s", script[currentStep].filename);

	loadVideo(filename);
	if ( cmov == NULL )
	{
		al_trace("Movie %s did not open for whatever reason.\r\n", filename);
		return;
	}

	if ( apeg_advance_stream(cmov, true) != APEG_OK)
	{
		al_trace("Video problem! Breakpoint!\r\n"); // doesn't really matter if it fails
	}
	blit(cmov->bitmap, frameData, 0, 0, 0, 0, 320, 192);
}
コード例 #3
0
ファイル: MediaServer.cpp プロジェクト: ARKopp/ofxPiMapper
 void MediaServer::unloadMedia(string &path) {
   if (loadedSources.count(path)) {
     BaseSource* mediaSource = getSourceByPath(path);
     if (mediaSource->getType() == SourceType::SOURCE_TYPE_IMAGE) {
       unloadImage(path);
     } else if (mediaSource->getType() == SourceType::SOURCE_TYPE_VIDEO) {
       unloadVideo(path);
     } else if (mediaSource->getType() == SourceType::SOURCE_TYPE_FBO) {
       unloadFboSource(path);
     } else {
       // Oh my god, what to do!? Relax and exit.
       ofLogFatalError("MediaServer") << "Attempt to unload media of unknown type";
       std::exit(EXIT_FAILURE);
     }
   } else {
     ofLogNotice("MediaServer") << "Nothing to unload";
   }
 }