Languages

Menu
Sites
Language
List all Music File of Device

Hello everyone, 

I had currently started working with the new project , i had to list all the music files available in my device , 

I am not getting any idea how to get those all Music Files from memory ?

If someone help me, it would be great .

Thank You, Dinal Jivani

View Selected Answer

Responses

4 Replies
Slawek Kowalski

You must scan all folders in the mediastorage, music folder at least.

Dinal Jivani

Yes Slawek Kowalski , 

thats what i also know , but the question is How ?

K Johnson

Hi Dinal Jivani,

Please go through MediaContent sample project from Tizen Studio. It'll give you clear idea about your requirement.

Mark as answer
Dinal Jivani

Hello , K Johnson

 

Thanks for your reply , but i had just found the solution

bool
Music_Display_Cb(media_info_h media, void *data)
{
    appdata_s *ad=data;
	id=calloc(sizeof(item_data_s),1);

	media_content_type_e Type;

	if ((media_info_get_display_name(media, &id->Title) == MEDIA_CONTENT_ERROR_NONE)
		&& (media_info_get_file_path(media, &id->Path) == MEDIA_CONTENT_ERROR_NONE)
		&& (media_info_get_media_type(media,&Type) == MEDIA_CONTENT_ERROR_NONE)
		)
	{
		if (Type == MEDIA_CONTENT_TYPE_MUSIC)
		{
            dlog_print(DLOG_INFO, LOG_TAG, "Found Music File : %s",ad->Title);
		}
	}
	return true;
}

if (media_content_connect() == MEDIA_CONTENT_ERROR_NONE)
{
	MusicFlag=0;
	if (media_info_foreach_media_from_db(NULL, Music_Display_Cb, ad) != MEDIA_CONTENT_ERROR_NONE)
	{
	   dlog_print(DLOG_ERROR, LOG_TAG, "Error occurred when trying to list media!");
	   media_content_disconnect();
	   return false;
	}
	if (media_content_disconnect() != MEDIA_CONTENT_ERROR_NONE)
	{
	   dlog_print(DLOG_ERROR, LOG_TAG, "Error occurred when disconnecting from media db!");
	   return false;
	}
	return true;
}

I got these working perfectly in my case :D :)