Skip to content

Commit

Permalink
QML Player supports changing notifyInterval
Browse files Browse the repository at this point in the history
  • Loading branch information
lvzhaobing committed Jun 15, 2020
1 parent cf2aaee commit 6b28547
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
9 changes: 7 additions & 2 deletions qml/QmlAV/QmlAVPlayer.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/******************************************************************************
/******************************************************************************
QtAV: Multimedia framework based on Qt and FFmpeg
Copyright (C) 2012-2017 Wang Bin <[email protected]>
Expand Down Expand Up @@ -98,6 +98,7 @@ class QmlAVPlayer : public QObject, public QQmlParserStatus
// TODO: startPosition/stopPosition
Q_PROPERTY(QStringList audioBackends READ audioBackends WRITE setAudioBackends NOTIFY audioBackendsChanged)
Q_PROPERTY(QStringList supportedAudioBackends READ supportedAudioBackends)
Q_PROPERTY(int notifyInterval READ notifyInterval WRITE setNotifyInterval NOTIFY notifyIntervalChanged)
public:
enum Loop { Infinite = -1 };
// use (1<<31)-1
Expand Down Expand Up @@ -280,6 +281,7 @@ class QmlAVPlayer : public QObject, public QQmlParserStatus
QStringList supportedAudioBackends() const;
QStringList audioBackends() const;
void setAudioBackends(const QStringList& value);
int notifyInterval() const;

public Q_SLOTS:
void play();
Expand All @@ -290,7 +292,7 @@ public Q_SLOTS:
void seek(int offset);
void seekForward();
void seekBackward();

void setNotifyInterval(int notifyInterval);
Q_SIGNALS:
void volumeChanged();
void mutedChanged();
Expand Down Expand Up @@ -340,6 +342,8 @@ public Q_SLOTS:
void statusChanged();
void mediaObjectChanged();
void audioBackendsChanged();
void notifyIntervalChanged(int notifyInterval);

private Q_SLOTS:
// connect to signals from player
void _q_error(const QtAV::AVError& e);
Expand Down Expand Up @@ -397,6 +401,7 @@ private Q_SLOTS:
QList<QuickAudioFilter*> m_afilters;
QList<QuickVideoFilter*> m_vfilters;
QStringList m_ao;
int m_notifyInterval;
};

#endif // QTAV_QML_AVPLAYER_H
18 changes: 17 additions & 1 deletion qml/QmlAVPlayer.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/******************************************************************************
/******************************************************************************
QtAV: Multimedia framework based on Qt and FFmpeg
Copyright (C) 2012-2017 Wang Bin <[email protected]>
Expand Down Expand Up @@ -89,6 +89,7 @@ void QmlAVPlayer::classBegin()
connect(mpPlayer, SIGNAL(seekableChanged()), SIGNAL(seekableChanged()));
connect(mpPlayer, SIGNAL(seekFinished(qint64)), this, SIGNAL(seekFinished()), Qt::DirectConnection);
connect(mpPlayer, SIGNAL(bufferProgressChanged(qreal)), SIGNAL(bufferProgressChanged()));
connect(mpPlayer, SIGNAL(notifyIntervalChanged), SIGNAL(notifyIntervalChanged()));
connect(this, SIGNAL(channelLayoutChanged()), SLOT(applyChannelLayout()));
// direct connection to ensure volume() in slots is correct
connect(mpPlayer->audio(), SIGNAL(volumeChanged(qreal)), SLOT(applyVolume()), Qt::DirectConnection);
Expand Down Expand Up @@ -604,6 +605,13 @@ void QmlAVPlayer::setAudioBackends(const QStringList &value)
Q_EMIT audioBackendsChanged();
}

int QmlAVPlayer::notifyInterval() const
{
if(!mpPlayer)
return -1;
return mpPlayer->notifyInterval();
}

QStringList QmlAVPlayer::supportedAudioBackends() const
{
return AudioOutput::backendsAvailable();
Expand Down Expand Up @@ -898,6 +906,14 @@ void QmlAVPlayer::seekBackward()
mpPlayer->seekBackward();
}

void QmlAVPlayer::setNotifyInterval(int notifyInterval)
{
if (!mpPlayer)
return;
mpPlayer->setNotifyInterval(notifyInterval);
}


void QmlAVPlayer::_q_error(const AVError &e)
{
mError = NoError;
Expand Down
3 changes: 2 additions & 1 deletion qml/Video.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@


import QtQuick 2.0
import QtAV 1.7

Expand Down Expand Up @@ -91,6 +91,7 @@ Item {
property alias internalVideoTracks: player.internalVideoTracks
property alias internalSubtitleTracks: player.internalSubtitleTracks
property alias internalSubtitleTrack: player.internalSubtitleTrack
property alias notifyInterval: player.notifyInterval
/*** Properties of VideoOutput ***/
/*!
\qmlproperty enumeration Video::fillMode
Expand Down

0 comments on commit 6b28547

Please sign in to comment.