How to receive signal from a static member functions?



  • Hi,all!
    In my pragram, I used the vlc to make a media player.
    I use the libvlc_event_attach to receive the event emit from vlc library,code as below:
    [code]
    void VLCMediaPlayerPrivate::setMedia(const QMediaContent &media)
    {

    QString mrl = media.canonicalUrl().toString();

    m_vlcMedia = libvlc_media_new_path( m_vlcInstance, mrl.toAscii());

    if (m_vlcMedia) {
    libvlc_event_manager_t *vlcEventManager = libvlc_media_event_manager(m_vlcMedia);
    if (vlcEventManager) {
    libvlc_event_attach(vlcEventManager, libvlc_MediaDurationChanged, durationChanged, this);
    }
    }
    // Put the media into the mediaplayer
    libvlc_media_player_set_media( m_vlcMediaPlayer, m_vlcMedia);
    }
    [/code]
    durationChanged is a static member function of class VLCMediaPlayerPrivate,and I passed the this pointer as user data to the libvlc_event_attach.And the durationChanged implements:
    [code]
    void VLCMediaPlayerPrivate::durationChanged(const struct libvlc_event_t event, void data)
    {
    if (data) {
    VLCMediaPlayerPrivate
    pthis = (VLCMediaPlayerPrivate
    )data;
    if (event->type == libvlc_MediaDurationChanged)
    pthis->emitDurationChanged(static_cast<qint64>(event->u.media_duration_changed.new_duration));
    }
    }
    [/code]
    emitDurationChanged is a non-static member function to emit a qt singals as belows:
    [code]
    void VLCMediaPlayerPrivate::emitDurationChanged(qint64 duration)
    {
    Q_Q(VLCMediaPlayer);
    m_duration = duration;
    Q_EMIT q->durationChanged(m_duration);
    }
    [/code]
    But I can't receive the durationChanged single, seems not working, this is why?



  • Anybody help?


  • Moderators

    what exactly doesn't work?
    Where is your connect() statement?
    Any output on the console?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.