Example #1
0
/**************************************************************************
 *        Play item at index (Public)
 **************************************************************************/
int libvlc_media_list_player_play_item_at_index(libvlc_media_list_player_t * p_mlp, int i_index)
{
    lock(p_mlp);
    set_current_playing_item(p_mlp, libvlc_media_list_path_with_root_index(i_index));
    libvlc_media_player_play(p_mlp->p_mi);
    unlock(p_mlp);

    /* Send the next item event */
    libvlc_event_t event;
    event.type = libvlc_MediaListPlayerNextItemSet;
    libvlc_event_send(p_mlp->p_event_manager, &event);
    return 0;
}
Example #2
0
/**************************************************************************
 *        Play item at index (Public)
 **************************************************************************/
void libvlc_media_list_player_play_item_at_index(libvlc_media_list_player_t * p_mlp, int i_index, libvlc_exception_t * p_e)
{
    VLC_UNUSED(p_e);

    lock(p_mlp);
    set_current_playing_item(p_mlp, libvlc_media_list_path_with_root_index(i_index));
    libvlc_media_player_play(p_mlp->p_mi, p_e);
    unlock(p_mlp);

    /* Send the next item event */
    libvlc_event_t event;
    event.type = libvlc_MediaListPlayerNextItemSet;
    libvlc_event_send(p_mlp->p_event_manager, &event);
}
Example #3
0
/**************************************************************************
 *        Play item (Public)
 **************************************************************************/
void libvlc_media_list_player_play_item(libvlc_media_list_player_t * p_mlp, libvlc_media_t * p_md, libvlc_exception_t * p_e)
{
    lock(p_mlp);
    libvlc_media_list_path_t path = libvlc_media_list_path_of_item(p_mlp->p_mlist, p_md);
    if (!path)
    {
        libvlc_exception_raise(p_e);
        libvlc_printerr("Item not found in media list");
        unlock(p_mlp);
        return;
    }
    
    set_current_playing_item(p_mlp, path);
    libvlc_media_player_play(p_mlp->p_mi, p_e);
    unlock(p_mlp);
}
Example #4
0
/**************************************************************************
 *        Play item (Public)
 **************************************************************************/
int libvlc_media_list_player_play_item(libvlc_media_list_player_t * p_mlp, libvlc_media_t * p_md)
{
    lock(p_mlp);
    libvlc_media_list_path_t path = libvlc_media_list_path_of_item(p_mlp->p_mlist, p_md);
    if (!path)
    {
        libvlc_printerr("Item not found in media list");
        unlock(p_mlp);
        return -1;
    }

    set_current_playing_item(p_mlp, path);
    libvlc_media_player_play(p_mlp->p_mi);
    unlock(p_mlp);
    return 0;
}
Example #5
0
/**************************************************************************
 *        Play item at index (Public)
 **************************************************************************/
int libvlc_media_list_player_play_item_at_index(libvlc_media_list_player_t * p_mlp, int i_index)
{
    lock(p_mlp);
    libvlc_media_list_path_t path = libvlc_media_list_path_with_root_index(i_index);
    set_current_playing_item(p_mlp, path);
    libvlc_media_t *p_md = libvlc_media_player_get_media(p_mlp->p_mi);
    libvlc_media_player_play(p_mlp->p_mi);
    unlock(p_mlp);

    if (!p_md)
        return -1;

    /* Send the next item event */
    libvlc_event_t event;
    event.type = libvlc_MediaListPlayerNextItemSet;
    event.u.media_list_player_next_item_set.item = p_md;
    libvlc_event_send(&p_mlp->event_manager, &event);
    libvlc_media_release(p_md);
    return 0;
}
Example #6
0
/**************************************************************************
 *       Set relative playlist position and play (Private)
 *
 * Sets the currently played item to the given relative play item position 
 * (based on the currently playing item) and then begins the new item playback.
 * Lock must be held.  
 **************************************************************************/
static void set_relative_playlist_position_and_play(
                                      libvlc_media_list_player_t * p_mlp, 
                                      int i_relative_position, 
                                      libvlc_exception_t * p_e)
{
    assert_locked(p_mlp);

    if (!p_mlp->p_mlist)
    {
        libvlc_exception_raise(p_e);
        libvlc_printerr("No media list");
        return;
    }

    libvlc_media_list_lock(p_mlp->p_mlist);

    libvlc_media_list_path_t path = p_mlp->current_playing_item_path;

    if(p_mlp->e_playback_mode != libvlc_playback_mode_repeat)
    {
        bool b_loop = (p_mlp->e_playback_mode == libvlc_playback_mode_loop);
        
        if(i_relative_position > 0)
        {
            do
            {
                path = get_next_path(p_mlp, b_loop);
                set_current_playing_item(p_mlp, path);
                --i_relative_position;
            }
            while(i_relative_position > 0);
        }
        else if(i_relative_position < 0)
        {
            do 
            {
                path = get_previous_path(p_mlp, b_loop);
                set_current_playing_item(p_mlp, path);
                ++i_relative_position;
            } 
            while (i_relative_position < 0);
        }
    }
    else
    {
        set_current_playing_item(p_mlp, path);
    }

#ifdef DEBUG_MEDIA_LIST_PLAYER
    printf("Playing:");
    libvlc_media_list_path_dump(path);
#endif

    if (!path)
    {
        libvlc_media_list_unlock(p_mlp->p_mlist);
        stop(p_mlp, p_e);
        return;
    }

    libvlc_media_player_play(p_mlp->p_mi, p_e);

    libvlc_media_list_unlock(p_mlp->p_mlist);

    /* Send the next item event */
    libvlc_event_t event;
    event.type = libvlc_MediaListPlayerNextItemSet;
    libvlc_media_t * p_md = libvlc_media_list_item_at_path(p_mlp->p_mlist, path);
    event.u.media_list_player_next_item_set.item = p_md;
    libvlc_event_send(p_mlp->p_event_manager, &event);
    libvlc_media_release(p_md);
}