Commit 115eba70 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Fix build due to recent media library breaking changes

parent ba72d52d
......@@ -35,15 +35,15 @@
#include "IArtist.h"
media_item*
fileToMediaItem( FilePtr file )
fileToMediaItem( MediaPtr file )
{
auto type = MEDIA_ITEM_TYPE_UNKNOWN;
switch ( file->type() )
{
case IFile::Type::VideoType:
case IMedia::Type::VideoType:
type = MEDIA_ITEM_TYPE_VIDEO;
break;
case IFile::Type::AudioType:
case IMedia::Type::AudioType:
type = MEDIA_ITEM_TYPE_AUDIO;
break;
default:
......@@ -60,10 +60,10 @@ fileToMediaItem( FilePtr file )
return nullptr;
}
mi->i_id = file->id();
media_item_set_meta(mi, MEDIA_ITEM_META_TITLE, file->name().c_str());
media_item_set_meta(mi, MEDIA_ITEM_META_TITLE, file->title().c_str());
mi->i_duration = file->duration();
if ( file->type() == IFile::Type::VideoType )
if ( file->type() == IMedia::Type::VideoType )
{
auto vtracks = file->videoTracks();
if ( vtracks.size() != 0 )
......@@ -77,26 +77,22 @@ fileToMediaItem( FilePtr file )
if (file->snapshot().length() > 0)
mi->psz_snapshot = strdup(file->snapshot().c_str());
}
else if ( file->type() == IFile::Type::AudioType )
else if ( file->type() == IMedia::Type::AudioType )
{
auto albumTrack = file->albumTrack();
if (albumTrack != nullptr)
auto artists = file->artists();
if (artists.size() > 0)
{
auto artists = albumTrack->artists();
if (artists.size() > 0)
std::string artistStr;
for ( auto& a : artists )
{
std::string artistStr;
for ( auto& a : artists )
{
artistStr += a->name() + ", ";
}
artistStr.erase( artistStr.length() - 2, 2 );
media_item_set_meta(mi, MEDIA_ITEM_META_ARTIST, artistStr.c_str());
}
else
{
media_item_set_meta(mi, MEDIA_ITEM_META_ARTIST, "Unknown Artist");
artistStr += a->name() + ", ";
}
artistStr.erase( artistStr.length() - 2, 2 );
media_item_set_meta(mi, MEDIA_ITEM_META_ARTIST, artistStr.c_str());
}
auto albumTrack = file->albumTrack();
if (albumTrack != nullptr)
{
auto album = albumTrack->album();
if (album != nullptr)
{
......@@ -140,18 +136,3 @@ artistToArtistItem( ArtistPtr artist )
return nullptr;
return p_item;
}
media_item*
albumTrackToItem( AlbumTrackPtr track )
{
auto files = track->files();
if (files.size() == 0)
{
LOGE("No file associated with audiotrack %s", track->title().c_str());
return nullptr;
}
if (files.size() > 1)
LOGW("More than a single file for this track, ignoring all but first one");
auto file = files[0];
return fileToMediaItem(file);
}
......@@ -43,19 +43,19 @@ media_library::media_library()
}
void
media_library::onFileAdded( FilePtr file )
media_library::onFileAdded( MediaPtr file )
{
sendFileUpdate( file, true );
}
void
media_library::onFileUpdated( FilePtr file )
media_library::onFileUpdated( MediaPtr file )
{
sendFileUpdate( file, false );
}
void
media_library::sendFileUpdate( FilePtr file, bool added )
media_library::sendFileUpdate( MediaPtr file, bool added )
{
auto item = fileToMediaItem( file );
auto ctx = new FileUpdateCallbackCtx{this, item, added};
......@@ -295,7 +295,7 @@ media_library_get_album_songs(media_library* p_ml, const char* psz_albumName, me
}
media_library_common_getter(cb, p_user_data,
std::bind(&IAlbum::tracks, album),
albumTrackToItem);
fileToMediaItem);
}
void
......
......@@ -27,17 +27,16 @@
#include <mutex>
#include "IAlbum.h"
#include "IFile.h"
#include "IMedia.h"
#include "ILogger.h"
#include "media_library.hpp"
#include "media/media_item.h"
#include "media/album_item.h"
#include "media/artist_item.h"
media_item* fileToMediaItem( FilePtr file );
media_item* fileToMediaItem( MediaPtr file );
album_item* albumToAlbumItem( AlbumPtr album );
artist_item* artistToArtistItem( ArtistPtr album );
media_item* albumTrackToItem( AlbumTrackPtr track );
class TizenLogger : public ILogger
{
......@@ -64,8 +63,8 @@ public:
virtual ~media_library() = default;
// IMediaLibraryCb
virtual void onFileAdded( FilePtr file ) override;
virtual void onFileUpdated( FilePtr file ) override;
virtual void onFileAdded( MediaPtr file ) override;
virtual void onFileUpdated( MediaPtr file ) override;
virtual void onDiscoveryStarted( const std::string& entryPoint ) override;
virtual void onDiscoveryCompleted( const std::string& entryPoint ) override;
......@@ -87,7 +86,7 @@ public:
std::shared_ptr<IMediaLibrary> ml;
private:
void sendFileUpdate( FilePtr item, bool added );
void sendFileUpdate( MediaPtr item, bool added );
private:
struct FileUpdateCallbackCtx
......
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