This is an automated email from the ASF dual-hosted git repository.

arielch pushed a commit to branch AOO418
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit deea6bb5c5c20c62b55cee14ce360b38efe7881a
Author: Herbert Dürr <[email protected]>
AuthorDate: Thu May 15 09:46:26 2014 +0000

    #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.
    
    
    git-svn-id: https://svn.apache.org/repos/asf/openoffice/trunk@1594838 
13f79535-47bb-0310-9956-ffa450edef68
    (cherry picked from commit 020bbb1d88621b9ceb9fc79a93df7017050e38c6)
---
 main/avmedia/source/macavf/macavf_player.cxx | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/main/avmedia/source/macavf/macavf_player.cxx 
b/main/avmedia/source/macavf/macavf_player.cxx
index 34c76d4..c9653ec 100644
--- a/main/avmedia/source/macavf/macavf_player.cxx
+++ b/main/avmedia/source/macavf/macavf_player.cxx
@@ -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;

Reply via email to