1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <wrapper/EventManager.hxx>
11 #include "SymbolLoader.hxx"
12 #include <wrapper/EventHandler.hxx>
17 libvlc_event_manager_t
* ( *libvlc_media_player_event_manager
) ( libvlc_media_player_t
*p_mi
);
18 int ( *libvlc_event_attach
) ( libvlc_event_manager_t
*p_event_manager
,
19 libvlc_event_type_t i_event_type
,
20 libvlc_callback_t f_callback
,
22 void ( *libvlc_event_detach
) ( libvlc_event_manager_t
*p_event_manager
,
23 libvlc_event_type_t i_event_type
,
24 libvlc_callback_t f_callback
,
34 void EventManager::Handler( const libvlc_event_t
*event
, void *pData
)
36 EventManager
*instance
= static_cast<EventManager
*>( pData
);
37 switch ( event
->type
)
39 case libvlc_MediaPlayerPaused
:
40 instance
->mEventHandler
.mCallbackQueue
.push( instance
->mOnPaused
);
42 case libvlc_MediaPlayerEndReached
:
43 instance
->mEventHandler
.mCallbackQueue
.push( instance
->mOnEndReached
);
48 bool EventManager::LoadSymbols()
50 static ApiMap
const VLC_EVENT_MANAGER_API
[] =
52 SYM_MAP( libvlc_media_player_event_manager
),
53 SYM_MAP( libvlc_event_attach
),
54 SYM_MAP( libvlc_event_detach
)
57 return InitApiMap( VLC_EVENT_MANAGER_API
);
60 EventManager::EventManager( Player
& player
, EventHandler
& eh
)
62 , mManager( libvlc_media_player_event_manager( player
) )
67 void EventManager::registerSignal( int signal
, const Callback
& callback
)
70 libvlc_event_detach( mManager
, signal
, Handler
, this );
72 libvlc_event_attach( mManager
, signal
, Handler
, this );
75 void EventManager::onPaused( const EventManager::Callback
& callback
)
78 registerSignal( libvlc_MediaPlayerPaused
, callback
);
81 void EventManager::onEndReached( const Callback
& callback
)
83 mOnEndReached
= callback
;
84 registerSignal( libvlc_MediaPlayerEndReached
, callback
);
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */