You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by hd...@apache.org on 2014/05/15 11:46:26 UTC

svn commit: r1594838 - /openoffice/trunk/main/avmedia/source/macavf/macavf_player.cxx

Author: hdu
Date: Thu May 15 09:46:26 2014
New Revision: 1594838

URL: http://svn.apache.org/r1594838
Log:
#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.

Modified:
    openoffice/trunk/main/avmedia/source/macavf/macavf_player.cxx

Modified: openoffice/trunk/main/avmedia/source/macavf/macavf_player.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/avmedia/source/macavf/macavf_player.cxx?rev=1594838&r1=1594837&r2=1594838&view=diff
==============================================================================
--- openoffice/trunk/main/avmedia/source/macavf/macavf_player.cxx (original)
+++ openoffice/trunk/main/avmedia/source/macavf/macavf_player.cxx Thu May 15 09:46:26 2014
@@ -218,7 +218,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;