Kaydet (Commit) d3ebac9e authored tarafından Herbert Dürr's avatar Herbert Dürr

#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.
üst c1498d16
...@@ -218,7 +218,10 @@ double SAL_CALL Player::getDuration() ...@@ -218,7 +218,10 @@ double SAL_CALL Player::getDuration()
if( mpPlayer ) if( mpPlayer )
{ {
AVPlayerItem* pItem = [mpPlayer currentItem]; 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; return duration;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment