Commit 2c7d0c0d authored by Mehdi Sabwat's avatar Mehdi Sabwat
Browse files

main.c : add click event handler

parent 9be7f8e0
......@@ -9,6 +9,7 @@
libvlc_media_player_t *mp;
libvlc_instance_t *libvlc;
libvlc_time_t t = -1;
char flag = 1;
void iter()
{
......@@ -21,6 +22,24 @@ void iter()
t = libvlc_media_player_get_time(mp);
}
static EM_BOOL play_pause_handler(int eventType, const EmscriptenMouseEvent *e, void *userData)
{
(void) e;
(void) userData; // To use when mp won't be a global.
if (eventType == EMSCRIPTEN_EVENT_CLICK)
{
if (flag == 1)
{
libvlc_media_player_play(mp);
flag = 0;
}
// Don't do that until you implement a/v synchro.
// libvlc_media_player_pause(mp);
// flag = 1;
}
return 0;
}
int main() {
/* We don't want to the main thread stop even if the main function exit.
......@@ -76,4 +95,8 @@ int main() {
emscripten_set_main_loop(iter, 1, 1);
return 0;
emscripten_set_click_callback("#canvas", 0, 1, play_pause_handler);
emscripten_set_main_loop(iter, 1, 1);
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment