Commit 47ab29d2 authored by Ludovic Fauvet's avatar Ludovic Fauvet

Basic background playback support

Allow playing a video as an audio-only file, in the background.
parent 25327eff
......@@ -355,3 +355,27 @@ media_list_get_repeat_mode(media_list *p_ml)
{
return p_ml->i_repeat;
}
// Copy a media list src to a media list dst, removing any previous element in dst.
int
media_list_copy_list(media_list *p_ml_src, media_list *p_ml_dst)
{
// Clear the destination
media_list_clear(p_ml_dst);
//while (media_list_get_count(p_ml_dst) > 0)
// media_list_remove_index(p_ml_dst, 0);
p_ml_dst->i_repeat = p_ml_src->i_repeat;
unsigned int items = media_list_get_count(p_ml_src);
for (int i = 0; i < items; i++)
{
media_item *item = media_list_get_item_at(p_ml_src, i);
if (item == NULL)
return -1;
if (!media_list_insert(p_ml_dst, -1, media_item_copy(item)))
return -1;
}
return 0;
}
......@@ -96,6 +96,9 @@ media_list_set_repeat_mode(media_list *p_ml, enum PLAYLIST_REPEAT i_repeat);
enum PLAYLIST_REPEAT
media_list_get_repeat_mode(media_list *p_ml);
int
media_list_copy_list(media_list *p_ml_src, media_list *p_ml_dst);
/*****************/
/* static helpers */
/*****************/
......
......@@ -959,3 +959,19 @@ playback_service_set_play_speed(playback_service *p_ps, double rate)
{
emotion_object_play_speed_set(p_ps->p_e, rate);
}
void
playback_service_enable_background_playback(playback_service *p_ps)
{
if (p_ps->i_ctx != PLAYLIST_CONTEXT_VIDEO)
return;
double time = playback_service_get_time(p_ps);
if (!media_list_copy_list(get_media_list(p_ps, PLAYLIST_CONTEXT_VIDEO), get_media_list(p_ps, PLAYLIST_CONTEXT_AUDIO)))
LOGE("Copying video playlist to audio failed");
if (!playback_service_set_context(p_ps, PLAYLIST_CONTEXT_AUDIO))
LOGE("Switching from video context to audio failed");
playback_service_start(p_ps, time);
}
......@@ -196,4 +196,7 @@ playback_service_get_play_speed(playback_service *p_ps);
void
playback_service_set_play_speed(playback_service *p_ps, double rate);
void
playback_service_enable_background_playback(playback_service *p_ps);
#endif /* PLAYBACK_SERVICE_H */
......@@ -160,6 +160,17 @@ audio_channel_selected(void *data, Evas_Object *obj, void *event_info)
evas_object_del(obj);
}
void
clicked_background_playback(void *data, Evas_Object *obj, void *event_info)
{
view_sys *p_sys = data;
if (p_sys->p_current_popup)
evas_object_del(p_sys->p_current_popup);
playback_service_enable_background_playback(p_sys->p_ps);
}
void
clicked_audio_tracks(void *data, Evas_Object *obj, void *event_info)
{
......@@ -265,8 +276,9 @@ clicked_spu(void *data, Evas_Object *obj, void *event_info)
static popup_menu menu_more[] =
{
{"Subtitles", NULL, clicked_spu},
{"Audio Tracks", NULL, clicked_audio_tracks},
{"Subtitles", NULL, clicked_spu},
{"Audio Tracks", NULL, clicked_audio_tracks},
{"Background playback", NULL, clicked_background_playback},
{0}
};
......
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