summaryrefslogtreecommitdiffstats
path: root/player/loadfile.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-04-11 01:23:32 +0200
committerwm4 <wm4@nowhere>2014-04-11 01:23:32 +0200
commit86094c2c5ae634b9ff02a85e51c33955b31babfa (patch)
treed7e99e5394d917f031e56d6a8e91c827f41d8475 /player/loadfile.c
parentd3e9f51c71a1691b76ee0918d228c5fe987e4ffa (diff)
downloadmpv-86094c2c5ae634b9ff02a85e51c33955b31babfa.tar.bz2
mpv-86094c2c5ae634b9ff02a85e51c33955b31babfa.tar.xz
client API: include the reason in MPV_EVENT_END_FILE
Otherwise, the client API user could not know why playback was stopped. Regarding the fact that 0 is used both for normal EOF and EOF on error: this is because mplayer traditionally did not distinguish these, and in general it's hard to tell the real reason. (There are various weird corner cases which make it hard.)
Diffstat (limited to 'player/loadfile.c')
-rw-r--r--player/loadfile.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/player/loadfile.c b/player/loadfile.c
index 95cc871e42..ee3deed4a8 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -1421,7 +1421,18 @@ terminate_playback: // don't jump here after ao/vo/getch initialization!
}
mp_notify(mpctx, MPV_EVENT_TRACKS_CHANGED, NULL);
- mp_notify(mpctx, MPV_EVENT_END_FILE, NULL);
+ struct mpv_event_end_file end_event = {0};
+ switch (mpctx->stop_play) {
+ case AT_END_OF_FILE: end_event.reason = 0; break;
+ case PT_RESTART:
+ case PT_RELOAD_DEMUXER: end_event.reason = 1; break;
+ case PT_NEXT_ENTRY:
+ case PT_CURRENT_ENTRY:
+ case PT_STOP: end_event.reason = 2; break;
+ case PT_QUIT: end_event.reason = 3; break;
+ default: end_event.reason = -1; break;
+ };
+ mp_notify(mpctx, MPV_EVENT_END_FILE, &end_event);
}
// Determine the next file to play. Note that if this function returns non-NULL,