Commit 830aa0a9 authored by Ludovic Fauvet's avatar Ludovic Fauvet

Simple playlist support

Playing a song from an audio view will add the entire list of items into
a playlist and start playback at the given index. Also makes the repeat
all works.
parent c3d89772
......@@ -952,7 +952,7 @@ ps_on_stopped_cb(playback_service *p_ps, void *p_user_data)
}
void
create_base_player(mini_player *mpd, const char *file_path)
create_base_player(mini_player *mpd, Eina_Array *array, int pos)
{
mini_player_reset_states(mpd);
......@@ -974,8 +974,21 @@ create_base_player(mini_player *mpd, const char *file_path)
playback_service_set_context(mpd->p_ps, PLAYLIST_CONTEXT_AUDIO);
playback_service_set_evas_video(mpd->p_ps, NULL);
playback_service_list_clear(mpd->p_ps);
media_item *p_mi = media_item_create(file_path, MEDIA_ITEM_TYPE_AUDIO);
playback_service_list_append(mpd->p_ps, p_mi);
media_item *p_mi;
Eina_Array_Iterator iterator;
unsigned int i;
EINA_ARRAY_ITER_NEXT(array, i, p_mi, iterator)
{
playback_service_list_append(mpd->p_ps, p_mi);
}
eina_array_free(array);
//media_item *p_mi = media_item_create(file_path, MEDIA_ITEM_TYPE_AUDIO);
//playback_service_list_append(mpd->p_ps, p_mi);
playback_service_list_set_pos(mpd->p_ps, pos);
playback_service_start(mpd->p_ps, 0);
update_player_display(mpd);
......
......@@ -35,7 +35,7 @@ mini_player*
mini_player_create(interface *intf, playback_service *p_ps, Evas_Object *layout);
void
create_base_player(mini_player *mpd, const char *file_path);
create_base_player(mini_player *mpd, Eina_Array *array, int pos);
void
mini_player_stop(mini_player *);
......
......@@ -376,9 +376,9 @@ intf_update_mini_player(interface *intf)
void
intf_create_audio_player(interface *intf, const char *psz_path)
intf_create_audio_player(interface *intf, Eina_Array *array, int pos)
{
create_base_player(intf->p_mini_player, psz_path);
create_base_player(intf->p_mini_player, array, pos);
}
static Evas_Object*
......
......@@ -88,7 +88,7 @@ void
intf_video_player_play(interface *intf, const char *psz_path);
void
intf_create_audio_player(interface *, const char *psz_path);
intf_create_audio_player(interface *intf, Eina_Array *array, int pos);
/* Mini Player */
bool
......
......@@ -124,7 +124,26 @@ static void
genlist_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
{
list_view_item *ali = data;
intf_create_audio_player(ali->p_list->p_intf, ali->p_media_item->psz_path);
int items = elm_genlist_items_count(ali->p_list->p_list);
Eina_Array *array = eina_array_new(items);
Elm_Object_Item *it;
int index = 0, pos = 0;
it = elm_genlist_first_item_get(ali->p_list->p_list);
do {
list_view_item *lvi = elm_object_item_data_get(it);
if (lvi == NULL)
continue;
if (media_item_identical(lvi->p_media_item, ali->p_media_item))
pos = index;
eina_array_push(array, media_item_copy(lvi->p_media_item));
index++;
} while ((it = elm_genlist_item_next_get(it)) != NULL);
intf_create_audio_player(ali->p_list->p_intf, array, pos);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment