#include "elevideo.h" #include "tools.h" #include #include #include static void *lock(void *opaque, void **planes) { auto that = (EleVideo *) opaque; that->imgRaw = QImage(that->mWidth, that->mHeight, QImage::Format_RGB32); *planes = that->imgRaw.bits(); /*tell VLC to put decoded data to this buffer*/ return 0; /* picture identifier, not needed here */ } static void unlock(void *opaque, void *picture, void *const *planes) { } static void display(void *opaque, void *picture) { auto that = (EleVideo *) opaque; that->emDisplay(that->imgRaw); } EleVideo::EleVideo(QString path, QWidget *parent) : QWidget{parent} { vlc = libvlc_new(0, NULL); auto pathChars = path.replace("/","\\").toUtf8(); auto media = libvlc_media_new_path(vlc, pathChars.data()); qDebug()<<"media"<img; // qDebug()<<"viCurTime"<viCurTime; // qDebug()<<"viSize"<viSize; //} void EleVideo::showEvent(QShowEvent *) { if(player!=nullptr) libvlc_media_player_play(player); } void EleVideo::hideEvent(QHideEvent *) { if(player!=nullptr) libvlc_media_player_stop(player); } void EleVideo::paintEvent(QPaintEvent *e) { QWidget::paintEvent(e); QPainter painter(this); painter.drawImage(QRectF(0, 0, width(), height()), img); }