![](/img/trans.png)
[英]How do I get current playing time, CMTime in milliseconds in AVPlayer?
[英]Pausing AVPlayer at a given CMTime
我正在為iOS 4.3及更高版本編寫一個應用程序,並使用automatic reference counting
。 我有一個使用AVPlayer
播放的視頻, CMTime
在達到給定的CMTime
時可以暫停該視頻。 我當前正在使用addBoundaryTimeObserverForTimes
並在被調用的block
內暫停AVPlayer
。 它有效,但是我收到錯誤消息:
Capturing 'self' strongly in this block is likely to lead to a retain cycle
我的代碼:
timeObserver = [player addBoundaryTimeObserverForTimes:endTime //An array of one NSValue representing a CMTime
queue:NULL
usingBlock:^{
[player pause];
}];
我無法找出正確的方法,非常感謝您的幫助。
謝謝!
您將必須使用__weak存儲裝飾器。
例如,將其放在您的阻止代碼之前:
__weak MYClass* blockSelf = self;
並在塊內使用blockSelf而不是self。
更新資料
剛剛在SO上找到了一個很好的答案: https : //stackoverflow.com/a/7854315/100848
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.