我是QT C ++的新手,我正在尝试使用Qmediaplayer库实现一个代码来传输视频。
这是我的代码:
#include "dialog.h"
#include <QApplication>
#include <QMediaPlayer>
#include <QVideoWidget>
#include <QDebug>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QMediaPlayer* player = new QMediaPlayer;
QVideoWidget* vw = new QVideoWidget;
player->setVideoOutput(vw);
player->setMedia(QUrl::fromLocalFile("/media/dimo/New Volume/Media/Video/anime/[AnyAnime.com] Boku no Hero Academia - Ova 02 [LQ].mp4"));
vw->setGeometry(100,100,300,400);
vw->show();
player->play();
qDebug() <<player->state();
return a.exec();
}
这是专业档案:
QT += core gui multimedia multimediawidgets
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = videoplayer
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
dialog.cpp
HEADERS += \
dialog.h
FORMS += \
dialog.ui
但它给了我这个错误: :-1:错误:找不到-lpulse-mainloop-glib :-1:错误:找不到-lpulse :-1:错误:collect2:错误:ld返回1退出状态