Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

Commit

Permalink
QML: added argument to stateChanged signal
Browse files Browse the repository at this point in the history
JS: added argument to MediaPlayerStateChanged event

fix #113
  • Loading branch information
RSATom committed Apr 28, 2015
1 parent 7c03266 commit 1d145a0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion deps/QmlVlc
15 changes: 14 additions & 1 deletion src/Chimera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ void Chimera::media_player_event( const libvlc_event_t* e )

void (JSRootAPI::*event_to_fire)(void) = 0;
bool fireStateChanged = false;
libvlc_state_t newState;

bool scheduleNotPlaying = false;

switch ( e->type ) {
Expand All @@ -68,17 +70,20 @@ void Chimera::media_player_event( const libvlc_event_t* e )
case libvlc_MediaPlayerNothingSpecial:
event_to_fire = &JSRootAPI::fire_MediaPlayerNothingSpecial;
fireStateChanged = true;
newState = libvlc_NothingSpecial;
break;
case libvlc_MediaPlayerOpening:
event_to_fire = &JSRootAPI::fire_MediaPlayerOpening;
fireStateChanged = true;
newState = libvlc_Opening;
break;
case libvlc_MediaPlayerBuffering:
h->ScheduleOnMainThread( api,
boost::bind( &JSRootAPI::fire_MediaPlayerBuffering,
api.get(),
e->u.media_player_buffering.new_cache ) );
fireStateChanged = true;
newState = libvlc_Buffering;
break;
case libvlc_MediaPlayerPlaying: {
boost::shared_ptr<Chimera> thisPtr = FB::ptr_cast<Chimera>( shared_from_this() );
Expand All @@ -88,17 +93,20 @@ void Chimera::media_player_event( const libvlc_event_t* e )

event_to_fire = &JSRootAPI::fire_MediaPlayerPlaying;
fireStateChanged = true;
newState = libvlc_Playing;
break;
}
case libvlc_MediaPlayerPaused:
event_to_fire = &JSRootAPI::fire_MediaPlayerPaused;
scheduleNotPlaying = true;
fireStateChanged = true;
newState = libvlc_Paused;
break;
case libvlc_MediaPlayerStopped:
event_to_fire = &JSRootAPI::fire_MediaPlayerStopped;
scheduleNotPlaying = true;
fireStateChanged = true;
newState = libvlc_Stopped;
break;
case libvlc_MediaPlayerForward:
event_to_fire = &JSRootAPI::fire_MediaPlayerForward;
Expand All @@ -110,11 +118,13 @@ void Chimera::media_player_event( const libvlc_event_t* e )
event_to_fire = &JSRootAPI::fire_MediaPlayerEndReached;
scheduleNotPlaying = true;
fireStateChanged = true;
newState = libvlc_Ended;
break;
case libvlc_MediaPlayerEncounteredError:
event_to_fire = &JSRootAPI::fire_MediaPlayerEncounteredError;
scheduleNotPlaying = true;
fireStateChanged = true;
newState = libvlc_Error;
break;
case libvlc_MediaPlayerTimeChanged: {
double new_time = static_cast<double>( e->u.media_player_time_changed.new_time );
Expand Down Expand Up @@ -168,7 +178,10 @@ void Chimera::media_player_event( const libvlc_event_t* e )
}

if( fireStateChanged ) {
h->ScheduleOnMainThread( api, boost::bind( &JSRootAPI::fire_MediaPlayerStateChanged, api.get() ) );
h->ScheduleOnMainThread( api,
boost::bind( &JSRootAPI::fire_MediaPlayerStateChanged,
api.get(),
newState ) );
}

if( scheduleNotPlaying ) {
Expand Down
2 changes: 1 addition & 1 deletion src/ChimeraAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ class JSRootAPI : public FB::JSAPIAuto
FB_JSAPI_EVENT( MediaPlayerPausableChanged, 1, ( bool ) );
FB_JSAPI_EVENT( MediaPlayerLengthChanged, 1, ( double ) );

FB_JSAPI_EVENT( MediaPlayerStateChanged, 0, () );
FB_JSAPI_EVENT( MediaPlayerStateChanged, 1, ( unsigned ) );

private:
ChimeraWeakPtr m_plugin;
Expand Down

0 comments on commit 1d145a0

Please sign in to comment.