forked from enlightenment/enlightenment
music control - support popup display of song position
look at property updates for position and track it and tell the popup about it along with loop mode.
This commit is contained in:
parent
b08ad06ede
commit
246d28d3bf
|
@ -238,6 +238,7 @@ parse_metadata(E_Music_Control_Module_Context *ctxt, Eina_Value *array)
|
|||
for (i = 0; i < eina_value_array_count(array); i++)
|
||||
{
|
||||
const char *key = NULL, *str_val;
|
||||
long long llval;
|
||||
char *str_markup;
|
||||
Eina_Value st, subst;
|
||||
Efreet_Uri *uri;
|
||||
|
@ -318,8 +319,17 @@ parse_metadata(E_Music_Control_Module_Context *ctxt, Eina_Value *array)
|
|||
}
|
||||
eina_value_flush(&subst);
|
||||
}
|
||||
else if (!strcmp(key, "mpris:length"))
|
||||
{
|
||||
llval = -1;
|
||||
if (eina_value_struct_value_get(&st, "arg1", &subst) &&
|
||||
eina_value_struct_get(&subst, "arg0", &llval))
|
||||
{
|
||||
ctxt->meta_length = (double)llval / 1000000.0;
|
||||
}
|
||||
eina_value_flush(&subst);
|
||||
}
|
||||
// FIXME: to handle in future:
|
||||
// mpris:length - int64
|
||||
// xesam:url - s
|
||||
}
|
||||
eina_value_flush(&st);
|
||||
|
@ -372,11 +382,31 @@ prop_changed(void *data, Eldbus_Proxy *proxy EINA_UNUSED, void *event_info)
|
|||
else ctxt->playing = EINA_FALSE;
|
||||
music_control_state_update_all(ctxt);
|
||||
}
|
||||
else if (!strcmp(event->name, "LoopStatus"))
|
||||
{
|
||||
const Eina_Value *value = event->value;
|
||||
const char *status;
|
||||
|
||||
eina_value_get(value, &status);
|
||||
if (!strcmp(status, "None")) ctxt->loop = EINA_FALSE;
|
||||
else if (!strcmp(status, "Track")) ctxt->loop = EINA_TRUE;
|
||||
if (!strcmp(status, "Playlist")) ctxt->loop = EINA_TRUE;
|
||||
music_control_state_update_all(ctxt);
|
||||
}
|
||||
else if (!strcmp(event->name, "Metadata"))
|
||||
{
|
||||
parse_metadata(ctxt, (Eina_Value*)event->value);
|
||||
music_control_metadata_update_all(ctxt);
|
||||
}
|
||||
else if (!strcmp(event->name, "Position"))
|
||||
{
|
||||
const Eina_Value *value = event->value;
|
||||
long long llval = 0;
|
||||
|
||||
eina_value_get(value, &llval);
|
||||
ctxt->position = (double)llval / 1000000.0;
|
||||
music_control_pos_update(ctxt);
|
||||
}
|
||||
}
|
||||
|
||||
static void _bus_list(E_Music_Control_Module_Context *ctxt);
|
||||
|
|
|
@ -23,6 +23,9 @@ typedef struct _E_Music_Control_Module_Context
|
|||
Eina_Stringshare *meta_title;
|
||||
Eina_Stringshare *meta_cover;
|
||||
Eina_Stringshare *meta_cover_prev;
|
||||
double meta_length;
|
||||
double position;
|
||||
Eina_Bool loop;
|
||||
Eldbus_Proxy *mrpis2;
|
||||
Eldbus_Proxy *mpris2_player;
|
||||
E_Config_DD *conf_edd;
|
||||
|
@ -47,6 +50,7 @@ void music_control_mouse_down_cb(void *data, Evas *evas, Evas_Object *obj, void
|
|||
const char *music_control_edj_path_get(void);
|
||||
void music_control_popup_del(E_Music_Control_Instance *inst);
|
||||
void music_control_state_update_all(E_Music_Control_Module_Context *ctxt);
|
||||
void music_control_pos_update(E_Music_Control_Module_Context *ctxt);
|
||||
void music_control_metadata_update_all(E_Music_Control_Module_Context *ctxt);
|
||||
Eina_Bool music_control_dbus_init(E_Music_Control_Module_Context *ctxt, const char *bus);
|
||||
|
||||
|
|
|
@ -2,6 +2,19 @@
|
|||
|
||||
extern Player music_player_players[];
|
||||
|
||||
static void
|
||||
_pos_update(E_Music_Control_Instance *inst)
|
||||
{
|
||||
Edje_Message_Float_Set *msg;
|
||||
|
||||
if (!inst->popup) return;
|
||||
msg = alloca(sizeof(Edje_Message_Float_Set) + (2 * sizeof(double)));
|
||||
msg->count = 2;
|
||||
msg->val[0] = inst->ctxt->position;
|
||||
msg->val[1] = inst->ctxt->meta_length;
|
||||
edje_object_message_send(inst->content_popup, EDJE_MESSAGE_FLOAT_SET, 1, msg);
|
||||
}
|
||||
|
||||
static void
|
||||
_play_state_update(E_Music_Control_Instance *inst, Eina_Bool without_delay)
|
||||
{
|
||||
|
@ -16,8 +29,14 @@ _play_state_update(E_Music_Control_Instance *inst, Eina_Bool without_delay)
|
|||
edje_object_signal_emit(inst->content_popup, "btn,state,image,play,no_delay", "play");
|
||||
else
|
||||
edje_object_signal_emit(inst->content_popup, "btn,state,image,play", "play");
|
||||
if (inst->ctxt->loop)
|
||||
edje_object_signal_emit(inst->content_popup, "loop,state,on", "play");
|
||||
else
|
||||
edje_object_signal_emit(inst->content_popup, "loop,state,off", "play");
|
||||
_pos_update(inst);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
music_control_state_update_all(E_Music_Control_Module_Context *ctxt)
|
||||
{
|
||||
|
@ -25,7 +44,21 @@ music_control_state_update_all(E_Music_Control_Module_Context *ctxt)
|
|||
Eina_List *list;
|
||||
|
||||
EINA_LIST_FOREACH(ctxt->instances, list, inst)
|
||||
_play_state_update(inst, EINA_FALSE);
|
||||
{
|
||||
_play_state_update(inst, EINA_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
music_control_pos_update(E_Music_Control_Module_Context *ctxt)
|
||||
{
|
||||
E_Music_Control_Instance *inst;
|
||||
Eina_List *list;
|
||||
|
||||
EINA_LIST_FOREACH(ctxt->instances, list, inst)
|
||||
{
|
||||
_pos_update(inst);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -146,6 +179,7 @@ _popup_new(E_Music_Control_Instance *inst)
|
|||
_player_name_update(inst);
|
||||
_play_state_update(inst, EINA_TRUE);
|
||||
_metadata_update(inst);
|
||||
_pos_update(inst);
|
||||
e_comp_object_util_autoclose(inst->popup->comp_object,
|
||||
_popup_autoclose_cb, NULL, inst);
|
||||
e_gadcon_popup_show(inst->popup);
|
||||
|
|
Loading…
Reference in New Issue