簡體   English   中英

在給定的CMTime暫停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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM