Commit f46e2b55 authored by michael's avatar michael

Fast seeking.

Try clicking with the mouse in the window, hold the button and drag.


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@21638 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 548574e0
...@@ -2327,6 +2327,7 @@ static void event_loop(void) ...@@ -2327,6 +2327,7 @@ static void event_loop(void)
double incr, pos, frac; double incr, pos, frac;
for(;;) { for(;;) {
double x;
SDL_WaitEvent(&event); SDL_WaitEvent(&event);
switch(event.type) { switch(event.type) {
case SDL_KEYDOWN: case SDL_KEYDOWN:
...@@ -2398,10 +2399,18 @@ static void event_loop(void) ...@@ -2398,10 +2399,18 @@ static void event_loop(void)
} }
break; break;
case SDL_MOUSEBUTTONDOWN: 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 (cur_stream) {
if(seek_by_bytes || cur_stream->ic->duration<=0){ if(seek_by_bytes || cur_stream->ic->duration<=0){
uint64_t size= url_fsize(cur_stream->ic->pb); 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{ }else{
int64_t ts; int64_t ts;
int ns, hh, mm, ss; int ns, hh, mm, ss;
...@@ -2410,7 +2419,7 @@ static void event_loop(void) ...@@ -2410,7 +2419,7 @@ static void event_loop(void)
thh = tns/3600; thh = tns/3600;
tmm = (tns%3600)/60; tmm = (tns%3600)/60;
tss = (tns%60); tss = (tns%60);
frac = (double)event.button.x/(double)cur_stream->width; frac = x/cur_stream->width;
ns = frac*tns; ns = frac*tns;
hh = ns/3600; hh = ns/3600;
mm = (ns%3600)/60; mm = (ns%3600)/60;
...@@ -2650,7 +2659,6 @@ int main(int argc, char **argv) ...@@ -2650,7 +2659,6 @@ int main(int argc, char **argv)
} }
SDL_EventState(SDL_ACTIVEEVENT, SDL_IGNORE); SDL_EventState(SDL_ACTIVEEVENT, SDL_IGNORE);
SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);
SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE); SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE);
SDL_EventState(SDL_USEREVENT, SDL_IGNORE); SDL_EventState(SDL_USEREVENT, SDL_IGNORE);
......
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