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
Leonhard Saam
libvlcpp
Commits
a490f041
Commit
a490f041
authored
May 05, 2020
by
Hugo Beauzée-Luyssen
Browse files
EventManager: Wrap new title events
parent
c20067af
Changes
2
Hide whitespace changes
Inline
Side-by-side
test/main.cpp
View file @
a490f041
...
...
@@ -105,6 +105,10 @@ int main(int ac, char** av)
auto
lFunc
=
std
::
function
<
void
(
float
)
>
{
l
};
auto
h1
=
mp
.
eventManager
().
onTimeChanged
(
lFunc
);
auto
h2
=
mp
.
eventManager
().
onPositionChanged
(
lFunc
);
mp
.
eventManager
().
onTitleSelectionChanged
(
[](
const
VLC
::
TitleDescription
&
t
,
int
idx
)
{
std
::
cout
<<
"New title selected: "
<<
t
.
name
()
<<
" at index "
<<
idx
<<
std
::
endl
;
});
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
seconds
(
2
)
);
...
...
vlcpp/EventManager.hpp
View file @
a490f041
...
...
@@ -612,6 +612,35 @@ class MediaPlayerEventManager : public EventManager
});
}
#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(4, 0, 0, 0)
/**
* \brief onTitleListChanged Registers an event called when the list of titles changes
* \param f A std::function<void(void)> (or an equivalent Callable type)
*
* The updated list can be obtained by calling MediaPlayer::titleDescription()
*/
template
<
typename
Func
>
RegisteredEvent
onTitleListChanged
(
Func
&&
f
)
{
return
handle
(
libvlc_MediaPlayerTitleListChanged
,
std
::
forward
<
Func
>
(
f
)
);
}
/**
* \brief onTitleSelectionChanged Registers an event called when the title selection changes
* \param f A std::function<void(const TitleDescription&, int)> (or an equivalent callable type)
*/
template
<
typename
Func
>
RegisteredEvent
onTitleSelectionChanged
(
Func
&&
f
)
{
EXPECT_SIGNATURE
(
void
(
const
TitleDescription
&
,
int
));
return
handle
(
libvlc_MediaPlayerTitleSelectionChanged
,
std
::
forward
<
Func
>
(
f
),
[](
const
libvlc_event_t
*
e
,
void
*
data
)
{
auto
callback
=
static_cast
<
DecayPtr
<
Func
>>
(
data
);
(
*
callback
)(
TitleDescription
{
e
->
u
.
media_player_title_selection_changed
.
title
},
e
->
u
.
media_player_title_selection_changed
.
index
);
});
}
#else
/**
* \brief onTitleChanged Registers an event called when the current title changes
* \param f A std::function<void(int)> (or an equivalent Callable type)
...
...
@@ -629,6 +658,7 @@ class MediaPlayerEventManager : public EventManager
(
*
callback
)(
e
->
u
.
media_player_title_changed
.
new_title
);
});
}
#endif
#if LIBVLC_VERSION_INT >= LIBVLC_VERSION(3, 0, 0, 0)
/**
...
...
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