mirror of
https://code.videolan.org/videolan/vlc
synced 2024-09-24 20:48:52 +02:00
player: Add a on_playback_restore_queried callback
And use it to ask the user if they want to resume the playback position when a last position is known by the media library
This commit is contained in:
parent
24ae03977d
commit
6a76cc6efa
@ -3032,6 +3032,22 @@ struct vlc_player_cbs
|
||||
*/
|
||||
void (*on_cork_changed)(vlc_player_t *player, unsigned cork_count,
|
||||
void *data);
|
||||
|
||||
/**
|
||||
* Called to query the user about restoring the previous playback position
|
||||
*
|
||||
* If this callback isn't provided, the user won't be asked to restore
|
||||
* the previous playback position, effectively causing
|
||||
* VLC_PLAYER_RESTORE_PLAYBACK_POS_ASK to be handled as
|
||||
* VLC_PLAYER_RESTORE_PLAYBACK_POS_NEVER
|
||||
*
|
||||
* The implementation can react to this callback by calling
|
||||
* vlc_player_RestorePlaybackPos(), or by discarding the event.
|
||||
*
|
||||
* @param player locked player instance
|
||||
* @param data opaque pointer set by vlc_player_AddListener()
|
||||
*/
|
||||
void (*on_playback_restore_queried)(vlc_player_t *player, void *data);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -949,7 +949,8 @@ static const struct vlc_player_cbs player_cbs = {
|
||||
on_player_media_epg_changed,
|
||||
on_player_subitems_changed,
|
||||
on_player_vout_changed,
|
||||
on_player_corks_changed
|
||||
on_player_corks_changed,
|
||||
nullptr
|
||||
};
|
||||
|
||||
static const struct vlc_player_vout_cbs player_vout_cbs = {
|
||||
|
@ -413,6 +413,7 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
|
||||
NULL, //on_player_subitems_changed,
|
||||
on_player_vout_changed,
|
||||
NULL, //on_player_corks_changed
|
||||
NULL, //on_playback_restore_queried
|
||||
};
|
||||
|
||||
static const struct vlc_player_vout_cbs player_vout_cbs = {
|
||||
|
@ -884,6 +884,7 @@ vlc_player_input_New(vlc_player_t *player, input_item_t *item)
|
||||
input->ml.states.progress = -1.f;
|
||||
input->ml.restore = VLC_RESTOREPOINT_NONE;
|
||||
input->ml.restore_states = false;
|
||||
input->ml.delay_restore = false;
|
||||
|
||||
input->thread = input_Create(player, input_thread_Events, input, item,
|
||||
player->resource, player->renderer);
|
||||
|
@ -59,6 +59,9 @@ vlc_player_input_RestoreMlStates(struct vlc_player_input* input, bool force_pos)
|
||||
input->ml.states.current_title == -1 &&
|
||||
input->ml.states.progress > .0f)
|
||||
input_SetPosition(input->thread, input->ml.states.progress, false);
|
||||
else if (restore_pos == VLC_PLAYER_RESTORE_PLAYBACK_POS_ASK &&
|
||||
input->ml.states.progress > .0f)
|
||||
input->ml.delay_restore = true;
|
||||
|
||||
if (!restore_states)
|
||||
return;
|
||||
|
@ -100,6 +100,11 @@ vlc_player_OpenNextMedia(vlc_player_t *player)
|
||||
}
|
||||
}
|
||||
vlc_player_SendEvent(player, on_current_media_changed, player->media);
|
||||
if (player->input && player->input->ml.delay_restore)
|
||||
{
|
||||
vlc_player_SendEvent(player, on_playback_restore_queried);
|
||||
player->input->ml.delay_restore = false;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user