diff options
author | Herbert Dürr <hdu@apache.org> | 2014-05-15 09:46:26 +0000 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2014-05-15 19:03:28 +0300 |
commit | 75c804c1be8acf4c3fc9935b81e696918f33fd9d (patch) | |
tree | 038226742d13cda689c06b1439bf89411985aac5 /avmedia | |
parent | The AVMedia framework is not deprecated (diff) | |
download | core-75c804c1be8acf4c3fc9935b81e696918f33fd9d.tar.gz core-75c804c1be8acf4c3fc9935b81e696918f33fd9d.zip |
AOO: #i124875# use AVAsset's best guess duration if AVPlayerItem isn't ready yet
in AV Foundation the most accurate media asset duration is available when the
AVPlayerItem's status changes to AVPlayerItemStatusReadyToPlay. There already
is an observer for this, but the upper layers expect getDuration() to be
synchronous and to return within a reasonable time. Since returning an
approximation is sufficient using the AVAsset's duration as fallback is fine.
Diffstat (limited to 'avmedia')
-rw-r--r-- | avmedia/source/macavf/player.mm | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/avmedia/source/macavf/player.mm b/avmedia/source/macavf/player.mm index 404083bde48a..751dbed4661e 100644 --- a/avmedia/source/macavf/player.mm +++ b/avmedia/source/macavf/player.mm @@ -216,7 +216,10 @@ double SAL_CALL Player::getDuration() if( mpPlayer ) { AVPlayerItem* pItem = [mpPlayer currentItem]; - duration = CMTimeGetSeconds( [pItem duration] ); + if( [pItem status] == AVPlayerItemStatusReadyToPlay ) + duration = CMTimeGetSeconds( [pItem duration] ); + else // fall back to AVAsset's best guess + duration = CMTimeGetSeconds( [[pItem asset] duration] ); } return duration; |