Browse code

Implement -onkeydown and -onmousedown options for ffplay.

Patch by Alexei Svitkine cout << name << "." << surname << "@" << "gmail.com".

See thread:
Subject: [FFmpeg-devel] new command-line option for ffplay
Date: Wed, 23 Jun 2010 09:13:50 -0400

Originally committed as revision 24037 to svn://svn.ffmpeg.org/ffmpeg/trunk

Alexei Svitkine authored on 2010/07/04 21:43:12
Showing 3 changed files
... ...
@@ -18,6 +18,7 @@ version <next>:
18 18
 - RTSP tunneling over HTTP
19 19
 - RTP depacketization of SVQ3
20 20
 - -strict inofficial replaced by -strict unofficial
21
+- ffplay -exitonkeydown and -exitonmousedown options added
21 22
 
22 23
 
23 24
 version 0.6:
... ...
@@ -108,6 +108,10 @@ Select the desired subtitle stream number, counting from 0. The number
108 108
 refers to the list of all the input subtitle streams. If it is greater
109 109
 than the number of subtitle streams minus one, then the last one is
110 110
 selected, if it is negative the subtitle rendering is disabled.
111
+@item -exitonkeydown
112
+Exit if any key is pressed.
113
+@item -exitonmousedown
114
+Exit if any mouse button is pressed.
111 115
 @end table
112 116
 
113 117
 @section While playing
... ...
@@ -260,6 +260,8 @@ static int error_recognition = FF_ER_CAREFUL;
260 260
 static int error_concealment = 3;
261 261
 static int decoder_reorder_pts= -1;
262 262
 static int autoexit;
263
+static int exit_on_keydown;
264
+static int exit_on_mousedown;
263 265
 static int loop=1;
264 266
 static int framedrop=1;
265 267
 
... ...
@@ -2819,6 +2821,10 @@ static void event_loop(void)
2819 2819
         SDL_WaitEvent(&event);
2820 2820
         switch(event.type) {
2821 2821
         case SDL_KEYDOWN:
2822
+            if (exit_on_keydown) {
2823
+                do_exit();
2824
+                break;
2825
+            }
2822 2826
             switch(event.key.keysym.sym) {
2823 2827
             case SDLK_ESCAPE:
2824 2828
             case SDLK_q:
... ...
@@ -2887,6 +2893,10 @@ static void event_loop(void)
2887 2887
             }
2888 2888
             break;
2889 2889
         case SDL_MOUSEBUTTONDOWN:
2890
+            if (exit_on_mousedown) {
2891
+                do_exit();
2892
+                break;
2893
+            }
2890 2894
         case SDL_MOUSEMOTION:
2891 2895
             if(event.type ==SDL_MOUSEBUTTONDOWN){
2892 2896
                 x= event.button.x;
... ...
@@ -3068,6 +3078,8 @@ static const OptionDef options[] = {
3068 3068
     { "sync", HAS_ARG | OPT_FUNC2 | OPT_EXPERT, {(void*)opt_sync}, "set audio-video sync. type (type=audio/video/ext)", "type" },
3069 3069
     { "threads", HAS_ARG | OPT_FUNC2 | OPT_EXPERT, {(void*)opt_thread_count}, "thread count", "count" },
3070 3070
     { "autoexit", OPT_BOOL | OPT_EXPERT, {(void*)&autoexit}, "exit at the end", "" },
3071
+    { "exitonkeydown", OPT_BOOL | OPT_EXPERT, {(void*)&exit_on_keydown}, "exit on key down", "" },
3072
+    { "exitonmousedown", OPT_BOOL | OPT_EXPERT, {(void*)&exit_on_mousedown}, "exit on mouse down", "" },
3071 3073
     { "loop", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&loop}, "set number of times the playback shall be looped", "loop count" },
3072 3074
     { "framedrop", OPT_BOOL | OPT_EXPERT, {(void*)&framedrop}, "drop frames when cpu is too slow", "" },
3073 3075
     { "window_title", OPT_STRING | HAS_ARG, {(void*)&window_title}, "set window title", "window title" },