summaryrefslogtreecommitdiff
path: root/ffplay.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2010-01-30 23:19:59 +0000
committerMichael Niedermayer <michaelni@gmx.at>2010-01-30 23:19:59 +0000
commit2ef4605373129d0f16b876386cd05963dc6be0fb (patch)
treead5955a62b6937a1ecf5e2c18f65fd991a98197f /ffplay.c
parentc55806e3a273b643f6e34c9806881fa2c777af0b (diff)
Fix seeking by bytes with the mouse and do so by default if the duration is
nonsense. Originally committed as revision 21563 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'ffplay.c')
-rw-r--r--ffplay.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/ffplay.c b/ffplay.c
index eaabefd481..8a346867de 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -971,7 +971,7 @@ static double get_master_clock(VideoState *is)
}
/* seek in the stream */
-static void stream_seek(VideoState *is, int64_t pos, int64_t rel)
+static void stream_seek(VideoState *is, int64_t pos, int64_t rel, int seek_by_bytes)
{
if (!is->seek_req) {
is->seek_pos = pos;
@@ -2319,11 +2319,11 @@ static void event_loop(void)
else
incr *= 180000.0;
pos += incr;
- stream_seek(cur_stream, pos, incr);
+ stream_seek(cur_stream, pos, incr, 1);
} else {
pos = get_master_clock(cur_stream);
pos += incr;
- stream_seek(cur_stream, (int64_t)(pos * AV_TIME_BASE), (int64_t)(incr * AV_TIME_BASE));
+ stream_seek(cur_stream, (int64_t)(pos * AV_TIME_BASE), (int64_t)(incr * AV_TIME_BASE), 0);
}
}
break;
@@ -2333,6 +2333,10 @@ static void event_loop(void)
break;
case SDL_MOUSEBUTTONDOWN:
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);
+ }else{
int64_t ts;
int ns, hh, mm, ss;
int tns, thh, tmm, tss;
@@ -2350,7 +2354,8 @@ static void event_loop(void)
ts = frac*cur_stream->ic->duration;
if (cur_stream->ic->start_time != AV_NOPTS_VALUE)
ts += cur_stream->ic->start_time;
- stream_seek(cur_stream, ts, 0);
+ stream_seek(cur_stream, ts, 0, 0);
+ }
}
break;
case SDL_VIDEORESIZE: