-
Parallel execution
Does anyone know how to create another line of execution? what I mean by that is given a movie trailer that pauses when the user presses <p>. To do that, the closest method to the actually solution would be something like this:
Code:
movie.play();
cin>>ch;
if(ch=='p') movie.stop();
but that is obviously wrong. Does anyone know how to set up another execution path so that the movie or whatever executes until the moment the user presses a key or some external event happens?
-
You need to either use threads or fork a new process, depending on what your needs are and what system you're on.
-
dont use cin
don't use cin
instead you'll need the program to read the keyboard buffer for 'p'
if it is pressed, paused
if not, do nothing
put that in the playmovie() function
*might require DirectX*
unless you can find a library that read keyboard buffer other than directx