Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
abaee12a
Commit
abaee12a
authored
Nov 20, 2009
by
JP Dinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skins2: Factor out repeated code and use var_SetVariant where applicable.
parent
0ccbd1e8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
48 deletions
+23
-48
modules/gui/skins2/vars/time.cpp
modules/gui/skins2/vars/time.cpp
+21
-48
modules/gui/skins2/vars/time.hpp
modules/gui/skins2/vars/time.hpp
+2
-0
No files found.
modules/gui/skins2/vars/time.cpp
View file @
abaee12a
...
...
@@ -17,14 +17,20 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
*
along with this program; if not, write to the Free Software
*
Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
* You should have received a copy of the GNU General Public License
along
*
with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "time.hpp"
#include <vlc_input.h>
#include "time.hpp"
inline
bool
StreamTime
::
havePosition
()
const
{
input_thread_t
*
p_input
=
getIntf
()
->
p_sys
->
p_input
;
return
p_input
&&
(
var_GetFloat
(
p_input
,
"position"
)
!=
0.0
);
}
void
StreamTime
::
set
(
float
percentage
,
bool
updateVLC
)
{
...
...
@@ -48,66 +54,33 @@ const string StreamTime::getAsStringPercent() const
const
string
StreamTime
::
getAsStringCurrTime
(
bool
bShortFormat
)
const
{
if
(
getIntf
()
->
p_sys
->
p_input
==
NULL
)
{
if
(
!
havePosition
()
)
return
"-:--:--"
;
}
vlc_value_t
pos
;
pos
.
f_float
=
0.0
;
var_Get
(
getIntf
()
->
p_sys
->
p_input
,
"position"
,
&
pos
);
if
(
pos
.
f_float
==
0.0
)
{
return
"-:--:--"
;
}
vlc_value_t
time
;
time
.
i_time
=
0L
;
var_Get
(
getIntf
()
->
p_sys
->
p_input
,
"time"
,
&
time
);
return
formatTime
(
time
.
i_time
/
1000000
,
bShortFormat
);
mtime_t
time
=
var_GetTime
(
getIntf
()
->
p_sys
->
p_input
,
"time"
);
return
formatTime
(
time
/
1000000
,
bShortFormat
);
}
const
string
StreamTime
::
getAsStringTimeLeft
(
bool
bShortFormat
)
const
{
if
(
getIntf
()
->
p_sys
->
p_input
==
NULL
)
{
if
(
!
havePosition
()
)
return
"-:--:--"
;
}
vlc_value_t
pos
;
var_Get
(
getIntf
()
->
p_sys
->
p_input
,
"position"
,
&
pos
);
if
(
pos
.
f_float
==
0.0
)
{
return
"-:--:--"
;
}
vlc_value_t
time
,
duration
;
var_Get
(
getIntf
()
->
p_sys
->
p_input
,
"time"
,
&
time
);
var_Get
(
getIntf
()
->
p_sys
->
p_input
,
"length"
,
&
duration
);
mtime_t
time
=
var_GetTime
(
getIntf
()
->
p_sys
->
p_input
,
"time"
),
duration
=
var_GetTime
(
getIntf
()
->
p_sys
->
p_input
,
"length"
);
return
formatTime
(
(
duration
.
i_time
-
time
.
i_time
)
/
1000000
,
bShortFormat
);
return
formatTime
(
(
duration
-
time
)
/
1000000
,
bShortFormat
);
}
const
string
StreamTime
::
getAsStringDuration
(
bool
bShortFormat
)
const
{
if
(
getIntf
()
->
p_sys
->
p_input
==
NULL
)
{
if
(
!
havePosition
()
)
return
"-:--:--"
;
}
vlc_value_t
pos
;
pos
.
f_float
=
0.0
;
var_Get
(
getIntf
()
->
p_sys
->
p_input
,
"position"
,
&
pos
);
if
(
pos
.
f_float
==
0.0
)
{
return
"-:--:--"
;
}
vlc_value_t
time
;
var_Get
(
getIntf
()
->
p_sys
->
p_input
,
"length"
,
&
time
);
return
formatTime
(
time
.
i_time
/
1000000
,
bShortFormat
);
mtime_t
time
=
var_GetTime
(
getIntf
()
->
p_sys
->
p_input
,
"length"
);
return
formatTime
(
time
/
1000000
,
bShortFormat
);
}
...
...
modules/gui/skins2/vars/time.hpp
View file @
abaee12a
...
...
@@ -51,6 +51,8 @@ public:
private:
/// Convert a number of seconds into "h:mm:ss" format
const
string
formatTime
(
int
seconds
,
bool
bShortFormat
)
const
;
/// Return true when there is a non-null input and its position is not 0.0.
bool
havePosition
()
const
;
};
#endif
Write
Preview
Markdown
is supported
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