コード例 #1
0
void
pragha_update_musicobject_change_tag(PraghaMusicobject *mobj, gint changed, PraghaMusicobject *nmobj)
{
	if (!changed)
		return;

	CDEBUG(DBG_VERBOSE, "Tags Updates: 0x%x", changed);

	if (changed & TAG_TNO_CHANGED) {
		pragha_musicobject_set_track_no(mobj, pragha_musicobject_get_track_no(nmobj));
	}
	if (changed & TAG_TITLE_CHANGED) {
		pragha_musicobject_set_title(mobj, pragha_musicobject_get_title(nmobj));
	}
	if (changed & TAG_ARTIST_CHANGED) {
		pragha_musicobject_set_artist (mobj, pragha_musicobject_get_artist(nmobj));
	}
	if (changed & TAG_ALBUM_CHANGED) {
		pragha_musicobject_set_album(mobj, pragha_musicobject_get_album(nmobj));
	}
	if (changed & TAG_GENRE_CHANGED) {
		pragha_musicobject_set_genre(mobj, pragha_musicobject_get_genre(nmobj));
	}
	if (changed & TAG_YEAR_CHANGED) {
		pragha_musicobject_set_year(mobj, pragha_musicobject_get_year(nmobj));
	}
	if (changed & TAG_COMMENT_CHANGED) {
		pragha_musicobject_set_comment(mobj, pragha_musicobject_get_comment(nmobj));
	}
}
コード例 #2
0
PraghaMusicobject *
pragha_musicobject_new_from_mtp_track (LIBMTP_track_t *track)
{
	PraghaMusicEnum *enum_map = NULL;
	PraghaMusicobject *mobj = NULL;
	gchar *mime_type = NULL, *uri = NULL;

	/* First chech mime_type */

	if (track->filetype == LIBMTP_FILETYPE_FLAC)
		mime_type = g_strdup ("audio/x-flac");
	else if (track->filetype == LIBMTP_FILETYPE_MP3)
		mime_type = g_strdup ("audio/mpeg");
	else if (track->filetype == LIBMTP_FILETYPE_OGG)
		mime_type = g_strdup ("audio/ogg");
	else if (track->filetype == LIBMTP_FILETYPE_WAV)
		mime_type = g_strdup ("audio/x-wav");
	else if (track->filetype == LIBMTP_FILETYPE_WMA)
		mime_type = g_strdup ("audio/x-ms-wma");
	else if (track->filetype == LIBMTP_FILETYPE_MP4)
		mime_type = g_strdup ("audio/x-m4a");
	else
		return NULL;

	uri = g_strdup_printf ("mtp://%i-%s", track->item_id, track->filename);

	CDEBUG(DBG_MOBJ, "Creating new musicobject to MTP: %s", uri);

	enum_map = pragha_music_enum_get();
	mobj = g_object_new (PRAGHA_TYPE_MUSICOBJECT,
	                     "file", uri,
	                     "mime-type", mime_type,
	                     "source", pragha_music_enum_map_get(enum_map, "MTP"),
	                     NULL);
	g_object_unref (enum_map);

	if (track->title)
		pragha_musicobject_set_title (mobj, track->title);
	if (track->artist)
		pragha_musicobject_set_artist (mobj, track->artist);
	if (track->album)
		pragha_musicobject_set_album (mobj, track->album);
	if (track->genre)
		pragha_musicobject_set_genre (mobj, track->genre);
	if (track->duration)
		pragha_musicobject_set_length (mobj, track->duration/1000);
	if (track->tracknumber)
		pragha_musicobject_set_track_no (mobj, track->tracknumber);
	if (track->samplerate)
		pragha_musicobject_set_samplerate (mobj, track->samplerate);
	if (track->nochannels)
		pragha_musicobject_set_channels (mobj, track->nochannels);

	g_free (uri);
	g_free (mime_type);

	return mobj;
}