# Smpeg won't stop playing

This topic is 4644 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi! In the project I'm currently working on we need to play a introsequence in the beginning of the game. We're using SDL and mpegfiles so I figured the easiest alternetive would be the SMPEGlibrary. After some installing and testing the video showed with sound on the screen, the only problem is that I can't pick up signals from the keyboard while playing the video. This is the templatecode of an example included in the downloaded version throught dev-cpp (extended with some keyreadingcode):
/*
SDL with SMPEG - Test

Hint: in the path of the EXE must exist a test.mpg!
in Examples\SMPEG you will find a MPEG-1 file :)
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <SDL/SDL.h>

#include <SMPEG/smpeg.h>

SDL_Surface *screen = NULL;

void shutdown(void){
SDL_Quit();
}

int main(int argc, char *argv[]){

SDL_Init(SDL_INIT_VIDEO);
atexit(shutdown);

screen = SDL_SetVideoMode(640,480,32,SDL_HWSURFACE | SDL_DOUBLEBUF);
SDL_WM_SetCaption("Dev-C++ SMPEG-Lib Test", NULL);

SDL_ShowCursor(SDL_DISABLE);

SMPEG_Info mpg_info;
SMPEGstatus mpg_status;
SMPEG* mpg = SMPEG_new("test.mpg",&mpg_info,1);

SMPEG_setdisplay(mpg,screen,NULL,NULL);
SMPEG_play(mpg);

mpg_status = SMPEG_status(mpg);

while(mpg_status == SMPEG_PLAYING){
SDL_Event event;
while ( SDL_PollEvent(&event) )
{
if ( event.type == SDL_QUIT )  {SMPEG_stop(mpg); }
if ( event.type == SDL_KEYDOWN )
{
if ( event.key.keysym.sym == SDLK_ESCAPE ) {SMPEG_stop(mpg);}
}
}
mpg_status = SMPEG_status(mpg);
//SDL_Delay(1000);
}

SMPEG_stop(mpg);
SMPEG_delete(mpg);
mpg = NULL;

SDL_ShowCursor(SDL_ENABLE);

return 0;
}


The code seems to freeze at the "SMPEG_play(mpg);"-line, nothing appears to happen after the call of that function, until the end of the movie. I've tried several other examples (compiled in VC6) and the exe-files runs fine with inputhandling, but if I try to compile the exact same code in dev-cpp (gcc, g++) it doesn't respond on a keydown. Thanks! //David

1. 1
2. 2
3. 3
Rutin
16
4. 4
5. 5

• 14
• 9
• 9
• 9
• 10
• ### Forum Statistics

• Total Topics
632912
• Total Posts
3009183
• ### Who's Online (See full list)

There are no registered users currently online

×