memcpy(&duration, pdu->params, sizeof(uint32_t));
duration = ntohl(duration);
+ media_player_set_duration(mp, duration);
memcpy(&position, pdu->params + 4, sizeof(uint32_t));
position = ntohl(position);
break;
case AVRCP_EVENT_TRACK_CHANGED:
mp = player->user_data;
- if (code == AVC_CTYPE_CHANGED)
- media_player_set_position(mp, 0);
avrcp_get_element_attributes(session);
+ if (code == AVC_CTYPE_CHANGED)
+ avrcp_get_play_status(session);
+
break;
case AVRCP_EVENT_SETTINGS_CHANGED:
return mp;
}
+void media_player_set_duration(struct media_player *mp, uint32_t duration)
+{
+ char *value, *curval;
+
+ DBG("%u", duration);
+
+ value = g_strdup_printf("%u", duration);
+
+ curval = g_hash_table_lookup(mp->track, "Duration");
+ if (g_strcmp0(curval, value) == 0) {
+ g_free(value);
+ return;
+ }
+
+ g_hash_table_replace(mp->track, g_strdup("Duration"), value);
+
+ g_dbus_emit_property_changed(btd_get_dbus_connection(),
+ mp->path, MEDIA_PLAYER_INTERFACE,
+ "Track");
+}
+
void media_player_set_position(struct media_player *mp, uint32_t position)
{
DBG("%u", position);
struct media_player *media_player_controller_create(const char *path);
void media_player_destroy(struct media_player *mp);
+void media_player_set_duration(struct media_player *mp, uint32_t duration);
void media_player_set_position(struct media_player *mp, uint32_t position);
void media_player_set_setting(struct media_player *mp, const char *key,
const char *value);