Code: Select all
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main(void){
int pidChild;
int pidParent;
int pid = fork();
if(pid == 0){
pidChild = getpid();
cout << "Child PID: " << pidChild << endl;
execlp("/usr/bin/omxplayer", "-r ", "/mnt/disk1/Videos/002.mp4", NULL);
//TODO: Send 'spacebar' to Omxplayer to pause playback
cout << "Playback loaded" << endl;
_exit(0);
}
else{
pidParent = getpid();
cout << "Parent PID: " << pidParent << endl;
//wait();
}
//External events occur here, simulate with sleep
sleep(5);
//TODO: Send 'spacebar' to Omxplayer to start playback
cout << "Playback start" << endl;
//External events occur here, simulate with sleep
sleep(5);
//TODO: Send 'q' or kill omxplayer
cout << "Playback end" << endl;
}