Beispiel #1
0
//libvlc events arrives from separate thread
void QmlVlcPlayerProxy::media_player_event( const libvlc_event_t* e )
{
    //LogEvent( e );

    switch ( e->type ) {
    case libvlc_MediaPlayerMediaChanged:
        Q_EMIT mediaPlayerMediaChanged();
        break;
    case libvlc_MediaPlayerNothingSpecial:
        Q_EMIT mediaPlayerNothingSpecial();
        break;
    case libvlc_MediaPlayerOpening:
        Q_EMIT mediaPlayerOpening();
        break;
    case libvlc_MediaPlayerBuffering:
        Q_EMIT mediaPlayerBuffering( e->u.media_player_buffering.new_cache );
        break;
    case libvlc_MediaPlayerPlaying:
        Q_EMIT mediaPlayerPlaying();
        break;
    case libvlc_MediaPlayerPaused:
        Q_EMIT mediaPlayerPaused();
        break;
    case libvlc_MediaPlayerStopped:
        Q_EMIT mediaPlayerStopped();
        break;
    case libvlc_MediaPlayerForward:
        Q_EMIT mediaPlayerForward();
        break;
    case libvlc_MediaPlayerBackward:
        Q_EMIT mediaPlayerBackward();
        break;
    case libvlc_MediaPlayerEndReached:
        Q_EMIT mediaPlayerEndReached();
        break;
    case libvlc_MediaPlayerEncounteredError:
        Q_EMIT mediaPlayerEncounteredError();
        break;
    case libvlc_MediaPlayerTimeChanged: {
        double new_time = static_cast<double>( e->u.media_player_time_changed.new_time );
        Q_EMIT mediaPlayerTimeChanged( new_time );
        break;
    }
    case libvlc_MediaPlayerPositionChanged:
        Q_EMIT mediaPlayerPositionChanged( e->u.media_player_position_changed.new_position );
        break;
    case libvlc_MediaPlayerSeekableChanged:
        Q_EMIT mediaPlayerSeekableChanged( e->u.media_player_seekable_changed.new_seekable != 0 );
        break;
    case libvlc_MediaPlayerPausableChanged:
        Q_EMIT mediaPlayerPausableChanged( e->u.media_player_pausable_changed.new_pausable != 0 );
        break;
    case libvlc_MediaPlayerTitleChanged:
        Q_EMIT mediaPlayerTitleChanged();
        break;
    case libvlc_MediaPlayerLengthChanged: {
            double new_length =
                static_cast<double>( e->u.media_player_length_changed.new_length );
            Q_EMIT mediaPlayerLengthChanged( new_length );
        }
        break;
    };
}
Beispiel #2
0
void QmlVlcPlayerProxy::handleLibvlcEvent( const LibvlcEvent& event )
{
    //it's highly possible libvlc_event_t will have wrong pointers inside at this point
    const libvlc_event_t* e = &event._libvlcEvent;

    //LogEvent( e );

    switch ( e->type ) {
    case libvlc_MediaPlayerMediaChanged:
        Q_EMIT mediaPlayerMediaChanged();
        Q_EMIT m_playlist.currentItemChanged();
        break;
    case libvlc_MediaPlayerNothingSpecial:
        Q_EMIT mediaPlayerNothingSpecial();
        Q_EMIT stateChanged( NothingSpecial );
        break;
    case libvlc_MediaPlayerOpening:
        Q_EMIT mediaPlayerOpening();
        Q_EMIT stateChanged( Opening );
        break;
    case libvlc_MediaPlayerBuffering:
        Q_EMIT mediaPlayerBuffering( e->u.media_player_buffering.new_cache );
        Q_EMIT stateChanged( Buffering );
        break;
    case libvlc_MediaPlayerPlaying:
        Q_EMIT mediaPlayerPlaying();
        Q_EMIT stateChanged( Playing );
        Q_EMIT playingChanged();
        break;
    case libvlc_MediaPlayerPaused:
        Q_EMIT mediaPlayerPaused();
        Q_EMIT stateChanged( Paused );
        Q_EMIT playingChanged();
        break;
    case libvlc_MediaPlayerStopped:
        Q_EMIT mediaPlayerStopped();
        Q_EMIT stateChanged( Stopped );
        Q_EMIT playingChanged();
        break;
    case libvlc_MediaPlayerForward:
        Q_EMIT mediaPlayerForward();
        break;
    case libvlc_MediaPlayerBackward:
        Q_EMIT mediaPlayerBackward();
        break;
    case libvlc_MediaPlayerEndReached:
        Q_EMIT mediaPlayerEndReached();
        Q_EMIT stateChanged( Ended );
        Q_EMIT playingChanged();
        break;
    case libvlc_MediaPlayerEncounteredError:
        Q_EMIT mediaPlayerEncounteredError();
        Q_EMIT stateChanged( Error );
        Q_EMIT playingChanged();
        break;
    case libvlc_MediaPlayerTimeChanged: {
        double new_time = static_cast<double>( e->u.media_player_time_changed.new_time );
        Q_EMIT mediaPlayerTimeChanged( new_time );
        break;
    }
    case libvlc_MediaPlayerPositionChanged:
        Q_EMIT mediaPlayerPositionChanged( e->u.media_player_position_changed.new_position );
        break;
    case libvlc_MediaPlayerSeekableChanged:
        Q_EMIT mediaPlayerSeekableChanged( e->u.media_player_seekable_changed.new_seekable != 0 );
        break;
    case libvlc_MediaPlayerPausableChanged:
        Q_EMIT mediaPlayerPausableChanged( e->u.media_player_pausable_changed.new_pausable != 0 );
        break;
    case libvlc_MediaPlayerTitleChanged:
        Q_EMIT mediaPlayerTitleChanged();
        Q_EMIT m_currentMediaDesc.titleChanged();
        break;
    case libvlc_MediaPlayerLengthChanged: {
            double new_length =
                static_cast<double>( e->u.media_player_length_changed.new_length );
            Q_EMIT mediaPlayerLengthChanged( new_length );
        }
        break;
    };
}