diff options
author | Yoann Lopes <yoann.lopes@theqtcompany.com> | 2015-09-04 18:04:51 +0200 |
---|---|---|
committer | Yoann Lopes <yoann.lopes@theqtcompany.com> | 2015-09-15 09:10:25 +0000 |
commit | 9c5292927e9f9668671f8e83ecdcc271515b9bf4 (patch) | |
tree | edb5e5070b21180757240821208f7900102ef1f0 /src/plugins/avfoundation/mediaplayer | |
parent | e9cf6670fe61f67c8f16ed0393086c07f88582dd (diff) | |
download | qtmultimedia-9c5292927e9f9668671f8e83ecdcc271515b9bf4.tar.gz |
AVFoundation: implemented QMediaPlayer::seekable.
Change-Id: Iaca8daa2460062954497b3e510dd1828953c80fd
Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>
Diffstat (limited to 'src/plugins/avfoundation/mediaplayer')
3 files changed, 19 insertions, 1 deletions
diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayercontrol.mm b/src/plugins/avfoundation/mediaplayer/avfmediaplayercontrol.mm index ca11ef297..1f4b42bf1 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 024f380ce..18bcb23e1 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 50ec1ffac..53cdebd82 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) { |