Ejemplo n.º 1
0
QmlVlcPlayerProxy::QmlVlcPlayerProxy( const std::shared_ptr<vlc::player>& player,
                                      QObject* parent /*= 0*/ )
    : QObject( parent ), m_player( player ), m_audio( *player ), m_input( *player ),
      m_playlist( this ), m_subtitle( *player ), m_video( *player ),
      m_currentMediaDesc( this )
{
    qRegisterMetaType<QmlVlcPlayerProxy::State>( "QmlVlcPlayerProxy::State" );

    m_errorTimer.setInterval( 1000 );
    m_errorTimer.setSingleShot( true );

    connect( this, SIGNAL( mediaPlayerEncounteredError() ),
             &m_errorTimer, SLOT( start() ) );
    connect( &m_errorTimer, SIGNAL( timeout() ),
             this, SLOT( currentItemEndReached() ) );

    connect( this, SIGNAL( mediaPlayerEndReached() ),
             &m_errorTimer, SLOT( stop() ) );
    connect( this, SIGNAL( mediaPlayerEndReached() ),
             this, SLOT( currentItemEndReached() ) );

    connect( this, SIGNAL( mediaPlayerMediaChanged() ),
             &m_errorTimer, SLOT( stop() ) );
    connect( this, &QmlVlcPlayerProxy::mediaPlayerMediaChanged,
             get_subtitle(), &QmlVlcSubtitle::eraseLoaded );

    connect( get_audio(), SIGNAL( volumeChanged() ),
             this, SIGNAL( volumeChanged() ) );
}
Ejemplo n.º 2
0
QmlVlcPlayerProxy::QmlVlcPlayerProxy( const std::shared_ptr<vlc::player>& player,
                                      QObject* parent /*= 0*/ )
    : QObject( parent ), m_player( player ), m_audio( *player ), m_input( *player ),
      m_playlist( this ), m_subtitle( *player ), m_video( *player ),
      m_currentMediaDesc( this )
{
    qRegisterMetaType<QmlVlcPlayerProxy::State>("QmlVlcPlayerProxy::State");

    m_errorTimer.setInterval( 1000 );
    m_errorTimer.setSingleShot( true );

    connect( this, SIGNAL( mediaPlayerPlaying() ),
             this, SIGNAL( playingChanged() ), Qt::QueuedConnection );
    connect( this, SIGNAL( mediaPlayerPaused() ),
             this, SIGNAL( playingChanged() ), Qt::QueuedConnection );
    connect( this, SIGNAL( mediaPlayerEncounteredError() ),
             this, SIGNAL( playingChanged() ), Qt::QueuedConnection );
    connect( this, SIGNAL( mediaPlayerEndReached() ),
             this, SIGNAL( playingChanged() ), Qt::QueuedConnection );
    connect( this, SIGNAL( mediaPlayerStopped() ),
             this, SIGNAL( playingChanged() ), Qt::QueuedConnection );

    connect( this, &QmlVlcPlayerProxy::mediaPlayerNothingSpecial,
        [this] () {
            Q_EMIT stateChanged( NothingSpecial );
        } );

    connect( this, &QmlVlcPlayerProxy::mediaPlayerOpening,
        [this] () {
            Q_EMIT stateChanged( Opening );
        } );

    connect( this, &QmlVlcPlayerProxy::mediaPlayerBuffering,
        [this] ( float ) {
            Q_EMIT stateChanged( Buffering );
        } );

    connect( this, &QmlVlcPlayerProxy::mediaPlayerPlaying,
        [this] () {
            Q_EMIT stateChanged( Playing );
        } );

    connect( this, &QmlVlcPlayerProxy::mediaPlayerPaused,
        [this] () {
            Q_EMIT stateChanged( Paused );
        } );

    connect( this, &QmlVlcPlayerProxy::mediaPlayerEncounteredError,
        [this] () {
            Q_EMIT stateChanged( Error );
        } );

    connect( this, &QmlVlcPlayerProxy::mediaPlayerEndReached,
        [this] () {
            Q_EMIT stateChanged( Ended );
        } );

    connect( this, &QmlVlcPlayerProxy::mediaPlayerStopped,
        [this] () {
            Q_EMIT stateChanged( Stopped );
        } );


    connect( this, SIGNAL( mediaPlayerEncounteredError() ),
             &m_errorTimer, SLOT( start() ) );
    connect( &m_errorTimer, SIGNAL( timeout() ),
             this, SLOT( currentItemEndReached() ) );

    connect( this, SIGNAL( mediaPlayerEndReached() ),
             &m_errorTimer, SLOT( stop() ) );
    connect( this, SIGNAL( mediaPlayerEndReached() ),
             this, SLOT( currentItemEndReached() ) );

    connect( this, SIGNAL( mediaPlayerMediaChanged() ),
             &m_errorTimer, SLOT( stop() ) );
    connect( this, SIGNAL( mediaPlayerMediaChanged() ),
             &m_playlist, SIGNAL( currentItemChanged() ), Qt::QueuedConnection );
    connect( this, &QmlVlcPlayerProxy::mediaPlayerMediaChanged,
             get_subtitle(), &QmlVlcSubtitle::eraseLoaded );

    connect( this, SIGNAL( mediaPlayerTitleChanged() ),
             &m_currentMediaDesc, SIGNAL( titleChanged() ), Qt::QueuedConnection );

    connect( get_audio(), SIGNAL( volumeChanged() ),
             this, SIGNAL( volumeChanged() ), Qt::QueuedConnection );
}