InputManager::InputManager( QObject *parent, intf_thread_t *_p_intf) :
QObject( parent ), p_intf( _p_intf )
{
+ i_old_playing_status = END_S;
p_input = NULL;
/* Subscribe to updates */
- connect( DialogsProvider::getInstance( p_intf )->fixed_timer,
- SIGNAL( timeout() ), this, SLOT( update() ) );
+ connect( THEDP->fixed_timer, SIGNAL( timeout() ), this, SLOT( update() ) );
}
InputManager::~InputManager()
void InputManager::update()
{
/// \todo Emit the signals only if it changed
- if( !p_input || p_input->b_die ) return;
+ if( !p_input ) return;
- if( p_input->b_dead )
+ if( p_input->b_dead || p_input->b_die )
{
emit positionUpdated( 0.0, 0, 0 );
emit navigationChanged( 0 );
- emit statusChanged( 0 ); // 0 = STOPPED, 1 = PAUSE, 2 = PLAY
+ emit statusChanged( 0 ); // 0 = STOPPED, 1 = PLAY, 2 = PAUSE
}
/* Update position */
}
emit nameChanged( text );
+ /* Update playing status */
+ var_Get( p_input, "state", &val );
+ val.i_int = val.i_int == PAUSE_S ? PAUSE_S : PLAYING_S;
+ if( i_old_playing_status != val.i_int )
+ {
+ i_old_playing_status = val.i_int;
+ emit statusChanged( val.i_int == PAUSE_S ? PAUSE_S : PLAYING_S );
+ }
}
void InputManager::sliderUpdate( float new_pos )
var_SetFloat( p_input, "position", new_pos );
}
+void InputManager::togglePlayPause()
+{
+ vlc_value_t state;
+ var_Get( p_input, "state", &state );
+ if( state.i_int != PAUSE_S )
+ {
+ /* A stream is being played, pause it */
+ state.i_int = PAUSE_S;
+ }
+ else
+ {
+ /* Stream is paused, resume it */
+ state.i_int = PLAYING_S;
+ }
+ var_Set( p_input, "state", state );
+ emit statusChanged( state.i_int );
+}
+
/**********************************************************************
* MainInputManager implementation. Wrap an input manager and
* take care of updating the main playlist input
im, SLOT( setInput( input_thread_t * ) ) );
}
+MainInputManager::~MainInputManager()
+{
+ if( p_input ) vlc_object_release( p_input );
+}
+
void MainInputManager::updateInput()
{
vlc_mutex_lock( &p_intf->change_lock );
}
vlc_mutex_unlock( &p_intf->change_lock );
}
+
+void MainInputManager::togglePlayPause()
+{
+ if( p_input == NULL )
+ {
+ playlist_Play( THEPL );
+ return;
+ }
+ getIM()->togglePlayPause();
+}