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

Media: Allow PlayCount to be modified by the user

parent dcbea797
......@@ -53,6 +53,7 @@ class IMedia
virtual int64_t duration() const = 0;
virtual std::shared_ptr<IShowEpisode> showEpisode() = 0;
virtual int playCount() const = 0;
virtual void increasePlayCount() = 0;
virtual const std::string& mrl() const = 0;
virtual bool addLabel( LabelPtr label ) = 0;
virtual bool removeLabel( LabelPtr label ) = 0;
......
......@@ -165,6 +165,12 @@ int Media::playCount() const
return m_playCount;
}
void Media::increasePlayCount()
{
m_playCount++;
m_changed = true;
}
const std::string& Media::mrl() const
{
return m_mrl;
......
......@@ -81,6 +81,7 @@ class Media : public IMedia, public DatabaseHelpers<Media, policy::MediaTable>
virtual bool removeLabel( LabelPtr label ) override;
virtual std::vector<LabelPtr> labels() override;
virtual int playCount() const override;
virtual void increasePlayCount() override;
virtual const std::string& mrl() const override;
virtual MoviePtr movie() override;
void setMovie( MoviePtr movie );
......
......@@ -155,3 +155,17 @@ TEST_F( Medias, Snapshot )
auto f2 = ml->file( "media.avi" );
ASSERT_EQ( f2->snapshot(), newSnapshot );
}
TEST_F( Medias, PlayCount )
{
auto f = ml->addFile( "media.avi", nullptr );
ASSERT_EQ( 0, f->playCount() );
f->increasePlayCount();
ASSERT_EQ( 1, f->playCount() );
f->save();
Reload();
f = std::static_pointer_cast<Media>( ml->file( "media.avi" ) );
ASSERT_EQ( 1, f->playCount() );
}
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