diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayercontrol.mm b/src/plugins/avfoundation/mediaplayer/avfmediaplayercontrol.mm index ca11ef29..1f4b42bf 100644 --- a/src/plugins/avfoundation/mediaplayer/avfmediaplayercontrol.mm +++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayercontrol.mm @@ -65,6 +65,8 @@ void AVFMediaPlayerControl::setSession(AVFMediaPlayerSession *session) connect(m_session, SIGNAL(error(int,QString)), this, SIGNAL(error(int,QString))); connect(m_session, &AVFMediaPlayerSession::playbackRateChanged, this, &AVFMediaPlayerControl::playbackRateChanged); + connect(m_session, &AVFMediaPlayerSession::seekableChanged, + this, &AVFMediaPlayerControl::seekableChanged); } QMediaPlayer::State AVFMediaPlayerControl::state() const diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.h b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.h index 024f380c..18bcb23e 100644 --- a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.h +++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.h @@ -109,6 +109,7 @@ Q_SIGNALS: void audioAvailableChanged(bool audioAvailable); void videoAvailableChanged(bool videoAvailable); void playbackRateChanged(qreal rate); + void seekableChanged(bool seekable); void error(int error, const QString &errorString); private: @@ -151,6 +152,7 @@ private: void setAudioAvailable(bool available); void setVideoAvailable(bool available); + void setSeekable(bool seekable); AVFMediaPlayerService *m_service; AVFVideoOutput *m_videoOutput; @@ -171,6 +173,7 @@ private: qint64 m_duration; bool m_videoAvailable; bool m_audioAvailable; + bool m_seekable; void *m_observer; }; diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm index 50ec1ffa..53cdebd8 100644 --- a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm +++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm @@ -377,6 +377,7 @@ AVFMediaPlayerSession::AVFMediaPlayerSession(AVFMediaPlayerService *service, QOb , m_duration(0) , m_videoAvailable(false) , m_audioAvailable(false) + , m_seekable(false) { m_observer = [[AVFMediaPlayerSessionObserver alloc] initWithMediaPlayerSession:this]; } @@ -453,6 +454,7 @@ void AVFMediaPlayerSession::setMedia(const QMediaContent &content, QIODevice *st setAudioAvailable(false); setVideoAvailable(false); + setSeekable(false); m_requestedPosition = -1; Q_EMIT positionChanged(position()); @@ -554,7 +556,16 @@ bool AVFMediaPlayerSession::isVideoAvailable() const bool AVFMediaPlayerSession::isSeekable() const { - return true; + return m_seekable; +} + +void AVFMediaPlayerSession::setSeekable(bool seekable) +{ + if (m_seekable == seekable) + return; + + m_seekable = seekable; + Q_EMIT seekableChanged(seekable); } QMediaTimeRange AVFMediaPlayerSession::availablePlaybackRanges() const @@ -806,6 +817,8 @@ void AVFMediaPlayerSession::processLoadStateChange() } } + setSeekable([[playerItem seekableTimeRanges] count] > 0); + // Get the native size of the video, and reset the bounds of the player layer AVPlayerLayer *playerLayer = [(AVFMediaPlayerSessionObserver*)m_observer playerLayer]; if (videoTrack && playerLayer) {