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

IMediaLibrary: Allow a media to be fetched with its ID

parent 4625675c
......@@ -146,6 +146,7 @@ class IMediaLibrary
virtual LabelPtr createLabel( const std::string& label ) = 0;
virtual bool deleteLabel( LabelPtr label ) = 0;
virtual MediaPtr media( int64_t mediaId ) const = 0;
virtual std::vector<MediaPtr> audioFiles( SortingCriteria sort = SortingCriteria::Default, bool desc = false ) const = 0;
virtual std::vector<MediaPtr> videoFiles( SortingCriteria sort = SortingCriteria::Default, bool desc = false ) const = 0;
virtual AlbumPtr album( int64_t id ) const = 0;
......
......@@ -249,6 +249,11 @@ void MediaLibrary::setVerbosity(LogLevel v)
Log::setLogLevel( v );
}
MediaPtr MediaLibrary::media( int64_t mediaId ) const
{
return Media::fetch( this, mediaId );
}
std::vector<MediaPtr> MediaLibrary::audioFiles( SortingCriteria sort, bool desc ) const
{
return Media::listAll( this, IMedia::Type::AudioType, sort, desc );
......
......@@ -65,6 +65,7 @@ class MediaLibrary : public IMediaLibrary, public IDeviceListerCb
virtual bool initialize( const std::string& dbPath, const std::string& thumbnailPath, IMediaLibraryCb* metadataCb ) override;
virtual void setVerbosity( LogLevel v ) override;
virtual MediaPtr media( int64_t mediaId ) const override;
virtual std::vector<MediaPtr> audioFiles( SortingCriteria sort, bool desc) const override;
virtual std::vector<MediaPtr> videoFiles( SortingCriteria sort, bool desc) const override;
......
......@@ -45,7 +45,7 @@ MediaLibraryTester::MediaLibraryTester()
std::shared_ptr<Media> MediaLibraryTester::media( int64_t id )
{
return Media::fetch( this, id );
return std::static_pointer_cast<Media>( MediaLibrary::media( id ) );
}
MediaPtr MediaLibraryTester::media( const std::string& path )
......
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