AVFoundation: implemented QMediaPlayer::seekable.
Change-Id: Iaca8daa2460062954497b3e510dd1828953c80fd Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user