Commit 6e87b14d authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

media library: Expose albums listing

parent a5a4db4d
......@@ -82,3 +82,13 @@ fileToMediaItem( FilePtr file )
}
return mi;
}
album_item*
albumToAlbumItem( AlbumPtr album )
{
auto p_item = album_item_create(album->title().c_str());
if (p_item == nullptr)
return nullptr;
p_item->i_release_date = album->releaseDate();
return p_item;
}
......@@ -262,6 +262,27 @@ media_library_get_video_files( media_library* p_ml, media_library_list_cb cb, vo
}, nullptr, nullptr, ctx );
}
void
media_library_get_albums(media_library* p_ml, media_library_list_cb cb, void* p_user_data)
{
auto ctx = new ml_callback_context( p_ml, cb, p_user_data );
ecore_thread_run( [](void* data, Ecore_Thread* ) {
auto ctx = reinterpret_cast<ml_callback_context*>( data );
auto albums = ctx->p_ml->ml->albums();
Eina_List *list = nullptr;
for ( auto& a : albums )
{
auto elem = albumToAlbumItem( a );
if ( elem == nullptr )
continue;
list = eina_list_append( list, elem );
}
ctx->list = list;
ecore_main_loop_thread_safe_call_async( intermediate_list_callback, ctx );
}, nullptr, nullptr, ctx );
}
void
media_library_register_on_change(media_library* ml, media_library_file_list_changed_cb cb, void* p_data)
{
......
......@@ -64,6 +64,9 @@ media_library_get_video_files( media_library* p_ml, media_library_list_cb cb, vo
void
media_library_get_audio_files( media_library* p_ml, media_library_list_cb cb, void* p_user_data );
void
media_library_get_albums( media_library* p_ml, media_library_list_cb cb, void* p_user_data );
void
media_library_register_on_change(media_library* ml, media_library_file_list_changed_cb cb, void* p_data);
......
......@@ -26,12 +26,15 @@
#include <mutex>
#include "IAlbum.h"
#include "IFile.h"
#include "ILogger.h"
#include "media_library.hpp"
#include "media/media_item.h"
#include "media/album_item.h"
media_item* fileToMediaItem( FilePtr file );
album_item* albumToAlbumItem( AlbumPtr album );
class TizenLogger : public ILogger
{
......
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