Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
VideoLAN
medialibrary
Commits
13438283
Commit
13438283
authored
Sep 23, 2015
by
Hugo Beauzée-Luyssen
Browse files
File: Allow duration to be set
parent
6f020c87
Changes
4
Hide whitespace changes
Inline
Side-by-side
include/IFile.h
View file @
13438283
...
...
@@ -27,6 +27,7 @@ class IFile
virtual
AlbumTrackPtr
albumTrack
()
=
0
;
virtual
bool
setAlbumTrack
(
AlbumTrackPtr
albumTrack
)
=
0
;
virtual
unsigned
int
duration
()
const
=
0
;
virtual
bool
setDuration
(
unsigned
int
duration
)
=
0
;
virtual
std
::
shared_ptr
<
IShowEpisode
>
showEpisode
()
=
0
;
virtual
bool
setShowEpisode
(
ShowEpisodePtr
showEpisode
)
=
0
;
virtual
int
playCount
()
const
=
0
;
...
...
src/File.cpp
View file @
13438283
...
...
@@ -88,6 +88,16 @@ unsigned int File::duration() const
return
m_duration
;
}
bool
File
::
setDuration
(
unsigned
int
duration
)
{
static
const
std
::
string
req
=
"UPDATE "
+
policy
::
FileTable
::
Name
+
" SET duration = ? "
"WHERE id_file = ?"
;
if
(
sqlite
::
Tools
::
executeUpdate
(
m_dbConnection
,
req
,
duration
,
m_id
)
==
false
)
return
false
;
m_duration
=
duration
;
return
true
;
}
std
::
shared_ptr
<
IShowEpisode
>
File
::
showEpisode
()
{
if
(
m_showEpisode
==
nullptr
&&
m_showEpisodeId
!=
0
)
...
...
src/File.h
View file @
13438283
...
...
@@ -49,6 +49,7 @@ class File : public IFile, public Cache<File, IFile, policy::FileTable, policy::
virtual
AlbumTrackPtr
albumTrack
();
virtual
bool
setAlbumTrack
(
AlbumTrackPtr
albumTrack
);
virtual
unsigned
int
duration
()
const
;
virtual
bool
setDuration
(
unsigned
int
duration
)
override
;
virtual
std
::
shared_ptr
<
IShowEpisode
>
showEpisode
();
virtual
bool
setShowEpisode
(
ShowEpisodePtr
showEpisode
);
virtual
bool
addLabel
(
LabelPtr
label
);
...
...
test/Files.cpp
View file @
13438283
...
...
@@ -76,3 +76,17 @@ TEST_F( Files, LastModificationDate )
auto
f2
=
ml
->
file
(
"/dev/seaotter"
);
ASSERT_EQ
(
f
->
lastModificationDate
(),
f2
->
lastModificationDate
()
);
}
TEST_F
(
Files
,
Duration
)
{
auto
f
=
ml
->
addFile
(
"/some/file"
);
ASSERT_EQ
(
f
->
duration
(),
0u
);
f
->
setDuration
(
123u
);
ASSERT_EQ
(
f
->
duration
(),
123u
);
Reload
();
f
=
ml
->
file
(
"/some/file"
);
ASSERT_EQ
(
f
->
duration
(),
123u
);
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment