summaryrefslogtreecommitdiff
path: root/ffplay.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2010-02-05 00:37:39 +0000
committerMichael Niedermayer <michaelni@gmx.at>2010-02-05 00:37:39 +0000
commitd52ec0029b916cd553bbc197f915abfbeef1b210 (patch)
treeda2898f7dd0e6796cc68e8e7092bc2f79ec2ad9a /ffplay.c
parentf430c7b6ac42d860455282436cfbb48a9927f1d1 (diff)
Fast seeking.
Try clicking with the mouse in the window, hold the button and drag. Originally committed as revision 21638 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'ffplay.c')
-rw-r--r--ffplay.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/ffplay.c b/ffplay.c
index dbe5001539..f6d21570cb 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -2327,6 +2327,7 @@ static void event_loop(void)
double incr, pos, frac;
for(;;) {
+ double x;
SDL_WaitEvent(&event);
switch(event.type) {
case SDL_KEYDOWN:
@@ -2398,10 +2399,18 @@ static void event_loop(void)
}
break;
case SDL_MOUSEBUTTONDOWN:
+ case SDL_MOUSEMOTION:
+ if(event.type ==SDL_MOUSEBUTTONDOWN){
+ x= event.button.x;
+ }else{
+ if(event.motion.state != SDL_PRESSED)
+ break;
+ x= event.motion.x;
+ }
if (cur_stream) {
if(seek_by_bytes || cur_stream->ic->duration<=0){
uint64_t size= url_fsize(cur_stream->ic->pb);
- stream_seek(cur_stream, size*(double)event.button.x/(double)cur_stream->width, 0, 1);
+ stream_seek(cur_stream, size*x/cur_stream->width, 0, 1);
}else{
int64_t ts;
int ns, hh, mm, ss;
@@ -2410,7 +2419,7 @@ static void event_loop(void)
thh = tns/3600;
tmm = (tns%3600)/60;
tss = (tns%60);
- frac = (double)event.button.x/(double)cur_stream->width;
+ frac = x/cur_stream->width;
ns = frac*tns;
hh = ns/3600;
mm = (ns%3600)/60;
@@ -2650,7 +2659,6 @@ int main(int argc, char **argv)
}
SDL_EventState(SDL_ACTIVEEVENT, SDL_IGNORE);
- SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);
SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE);
SDL_EventState(SDL_USEREVENT, SDL_IGNORE);