Skip to content

Commit

Permalink
command: improve playlist* properties change notifications
Browse files Browse the repository at this point in the history
Until now, only the "playlist" property itself had proper change
notification. Extend it to all other properties as well.

Fixes #3267 (hopefully).
  • Loading branch information
wm4 committed Jun 20, 2016
1 parent fc50f37 commit 22291a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
15 changes: 9 additions & 6 deletions player/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -3950,7 +3950,10 @@ static const char *const *const mp_event_property_change[] = {
"demuxer-cache-duration", "demuxer-cache-idle", "paused-for-cache",
"demuxer-cache-time", "cache-buffering-state", "cache-speed"),
E(MP_EVENT_WIN_RESIZE, "window-scale", "osd-width", "osd-height", "osd-par"),
E(MP_EVENT_WIN_STATE, "window-minimized", "display-names", "display-fps", "fullscreen"),
E(MP_EVENT_WIN_STATE, "window-minimized", "display-names", "display-fps",
"fullscreen"),
E(MP_EVENT_CHANGE_PLAYLIST, "playlist", "playlist-pos", "playlist-pos-1",
"playlist-count", "playlist/count"),
};
#undef E

Expand Down Expand Up @@ -4869,7 +4872,7 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re
mp_write_watch_later_conf(mpctx);
mp_set_playlist_entry(mpctx, entry);
}
mp_notify_property(mpctx, "playlist");
mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
break;
}

Expand All @@ -4888,7 +4891,7 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re
if (!append && mpctx->playlist->first)
mp_set_playlist_entry(mpctx, new ? new : mpctx->playlist->first);

mp_notify_property(mpctx, "playlist");
mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
} else {
MP_ERR(mpctx, "Unable to load playlist %s.\n", filename);
return -1;
Expand All @@ -4909,7 +4912,7 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re
}
playlist_remove(mpctx->playlist, e);
}
mp_notify_property(mpctx, "playlist");
mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
break;
}

Expand All @@ -4924,7 +4927,7 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re
if (mpctx->playlist->current == e && !mpctx->stop_play)
mpctx->stop_play = PT_CURRENT_ENTRY;
playlist_remove(mpctx->playlist, e);
mp_notify_property(mpctx, "playlist");
mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
break;
}

Expand All @@ -4936,7 +4939,7 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re
if (!e1)
return -1;
playlist_move(mpctx->playlist, e1, e2);
mp_notify_property(mpctx, "playlist");
mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
break;
}

Expand Down
1 change: 1 addition & 0 deletions player/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ enum {
MP_EVENT_CACHE_UPDATE,
MP_EVENT_WIN_RESIZE,
MP_EVENT_WIN_STATE,
MP_EVENT_CHANGE_PLAYLIST,
};

bool mp_hook_test_completion(struct MPContext *mpctx, char *type);
Expand Down

0 comments on commit 22291a2

Please sign in to comment.