Lomse library. API documentation  0.30.0
EventPlayCtrl Class Reference

#include <lomse_events.h>

Inheritance diagram for EventPlayCtrl:
EventAction EventInfo

Detailed Description

An object holding information about an score player control event. The event type informs the user application about the specific action.

This event is generated only from LMD documents with embedded controls (buttons, links, etc.). In particular, these events are generated by the ScorePlayerCtrl object associated to an ImoScorePlayer object embedded in the Document. These events inform about a user action on any of the buttons of the ScorePlayerCtrl, so that the user application can perform the expected actions associated to these buttons. If your application is oriented to process scores in MusicXML format or regular LDP files without embedded controls you will never receive these event types.

Example

For instance, in an application oriented to process LMD documents with embedded controls, written using the wxWidgets framework, you could handle these events as follows:

void DocumentWindow::display_document(const string& filename, ostringstream& reporter)
{
...
if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
//register to receive desired events
spInteractor->add_event_handler(k_update_window_event, this, wrapper_update_window);
spInteractor->add_event_handler(k_do_play_score_event, this, wrapper_play_score);
spInteractor->add_event_handler(k_pause_score_event, this, wrapper_play_score);
spInteractor->add_event_handler(k_stop_playback_event, this, wrapper_play_score);
...
}
void DocumentWindow::wrapper_play_score(void* pThis, SpEventInfo pEvent)
{
static_cast<DocumentWindow*>(pThis)->on_play_score(pEvent);
}
void DocumentWindow::on_play_score(SpEventInfo pEvent)
{
switch (pEvent->get_event_type())
{
play_score(pEvent);
return;
play_pause();
return;
default:
play_stop();
return;
}
}
void DocumentWindow::play_score(SpEventInfo pEvent)
{
if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
spInteractor->set_operating_mode(Interactor::k_mode_playback);
SpEventPlayCtrl pEv = static_pointer_cast<EventPlayCtrl>(pEvent);
ImoScore* pScore = pEv->get_score();
ScorePlayer* pPlayer = m_appScope.get_score_player();
PlayerGui* pPlayerGui = pEv->get_player();
pPlayer->load_score(pScore, pEv->get_player());
//initialize with default options
bool fVisualTracking = true;
long nMM = pPlayerGui->get_metronome_mm();
pPlayer->play(fVisualTracking, nMM, spInteractor.get());
}
}
void DocumentWindow::play_stop()
{
ScorePlayer* pPlayer = m_appScope.get_score_player();
pPlayer->stop();
if (SpInteractor spInteractor = m_pPresenter->get_interactor(0).lock())
{
spInteractor->set_operating_mode(is_edition_enabled() ? Interactor::k_mode_edition
}
}
void DocumentWindow::play_pause()
{
ScorePlayer* pPlayer = m_appScope.get_score_player();
pPlayer->pause();
}

Public Member Functions

 EventPlayCtrl (EEventType evType, WpInteractor wpInteractor, WpDocument wpDoc, ImoScore *pScore, PlayerGui *pPlayer)
 
ImoScore * get_score () const
 
PlayerGui * get_player () const
 
- Public Member Functions inherited from EventAction
virtual ~EventAction ()
 
WpInteractor get_interactor ()
 
WpDocument get_document ()
 
bool is_still_valid ()
 
- Public Member Functions inherited from EventInfo
virtual ~EventInfo ()
 
virtual Observableget_source ()
 
EEventType get_event_type ()
 
bool is_doc_modified_event ()
 
bool is_update_window_event ()
 
bool is_mouse_in_event ()
 
bool is_mouse_out_event ()
 
bool is_on_click_event ()
 
bool is_link_clicked_event ()
 
bool is_show_contextual_menu_event ()
 
bool is_control_point_moved_event ()
 
bool is_selection_set_change ()
 
bool is_pointed_object_change ()
 
bool is_do_play_score_event ()
 
bool is_pause_score_event ()
 
bool is_stop_playback_event ()
 
bool is_tracking_event ()
 
bool is_update_viewport_event ()
 
bool is_end_of_playback_event ()
 

Constructor & Destructor Documentation

◆ EventPlayCtrl()

EventPlayCtrl::EventPlayCtrl ( EEventType  evType,
WpInteractor  wpInteractor,
WpDocument  wpDoc,
ImoScore *  pScore,
PlayerGui *  pPlayer 
)
inline

Constructor.

Member Function Documentation

◆ get_player()

PlayerGui* EventPlayCtrl::get_player ( ) const
inline

Returns a ptr. to the PlayerGui object associated with this score playback.

◆ get_score()

ImoScore* EventPlayCtrl::get_score ( ) const
inline

Returns a ptr. to the score affected by the event.