mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Fix QMediaPlayer usage in Qt6
This commit is contained in:
parent
75060d4f24
commit
e91481d0c3
@ -287,26 +287,14 @@ void YACReaderTranslator::populateCombos()
|
|||||||
|
|
||||||
void YACReaderTranslator::play()
|
void YACReaderTranslator::play()
|
||||||
{
|
{
|
||||||
// QMessageBox::question(this,"xxx",ttsSource.toString());
|
|
||||||
#if QT_VERSION >= 0x050000
|
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
player->setSource(ttsSource);
|
||||||
|
#else
|
||||||
player->setMedia(ttsSource);
|
player->setMedia(ttsSource);
|
||||||
|
#endif
|
||||||
|
|
||||||
player->play();
|
player->play();
|
||||||
|
|
||||||
#else
|
|
||||||
MediaSource src(ttsSource);
|
|
||||||
src.setAutoDelete(true);
|
|
||||||
music->setCurrentSource(src);
|
|
||||||
music->play();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
YACReaderTranslator::~YACReaderTranslator()
|
|
||||||
{
|
|
||||||
#if QT_VERSION >= 0x050000
|
|
||||||
#else
|
|
||||||
delete music;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void YACReaderTranslator::mousePressEvent(QMouseEvent *event)
|
void YACReaderTranslator::mousePressEvent(QMouseEvent *event)
|
||||||
|
@ -15,19 +15,13 @@ class YACReaderBusyWidget;
|
|||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include "viewer.h"
|
#include "viewer.h"
|
||||||
|
|
||||||
#if QT_VERSION >= 0x050000
|
|
||||||
class QMediaPlayer;
|
class QMediaPlayer;
|
||||||
#else
|
|
||||||
#include <Phonon/MediaObject>
|
|
||||||
using namespace Phonon;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class YACReaderTranslator : public QWidget
|
class YACReaderTranslator : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
YACReaderTranslator(Viewer *parent = nullptr);
|
YACReaderTranslator(Viewer *parent = nullptr);
|
||||||
~YACReaderTranslator() override;
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void play();
|
void play();
|
||||||
@ -50,11 +44,7 @@ protected:
|
|||||||
QPoint click;
|
QPoint click;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if QT_VERSION >= 0x050000
|
|
||||||
QMediaPlayer *player;
|
QMediaPlayer *player;
|
||||||
#else
|
|
||||||
MediaObject *music;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QTextEdit *text;
|
QTextEdit *text;
|
||||||
QComboBox *from;
|
QComboBox *from;
|
||||||
|
Loading…
Reference in New Issue
Block a user