[Libreoffice-commits] core.git: avmedia/source
Herbert Dürr
hdu at apache.org
Thu May 15 09:05:16 PDT 2014
avmedia/source/macavf/player.mm | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
New commits:
commit 75c804c1be8acf4c3fc9935b81e696918f33fd9d
Author: Herbert Dürr <hdu at apache.org>
Date: Thu May 15 09:46:26 2014 +0000
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.
diff --git a/avmedia/source/macavf/player.mm b/avmedia/source/macavf/player.mm
index 404083b..751dbed 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;
More information about the Libreoffice-commits
mailing list