0
self.loadingView.frame = _frameWhereItShouldBeLocated;
[self.loadSpinner startAnimating]; // self.loadSpinner is an UIActivityIndicatorView
self.loadingView.hidden = FALSE;
AVPlayer *player = [AVPlayer playerWithURL:fileUrl]; // fileUrl is where is the video file is hosted, which is not a local path
if ([player.currentItem.asset isPlayable])
{
if (!self.playerController) {
self.playerController = [[AVPlayerViewController alloc] init];
self.playerController.transitioningDelegate = self;
self.playerController.modalPresentationStyle = UIModalPresentationCustom;
}
self.playerController.player = player;
self.playerController.showsPlaybackControls = TRUE;
[self.navigationController presentViewController:self.playerController animated:YES completion:nil];
[self.playerController.player play];
}
로딩 뷰는 사용자가 탭한 직후에 표시되고 잠시 후 플레이어 컨트롤러가 표시되어 비디오를 재생합니다. 그러나로드 뷰가 표시되기 전에 상당한 지연이 발생합니다.
User tap -> loading view shown -> (some time for loading the video, etc) -> play video
대신이 내가있어 무엇 :
이
내가 기대했던 것입니다User tap -> (significant time delay) -> loading view shown -> play video
나는 지연이 즉, [player.currentItem.asset isPlayable]
호출에 의해 발생되는 것을 발견 디버깅 후 불러 오기 뷰는 호출이 반환 된 후에 만 표시됩니다. 나는 dispatch_async
콜에서 뷰를로드하는 디스플레이 아래에 세그먼트를 놓으려고했으나 아무런 변화도 없었습니다.
예상대로 동작하도록하기 위해이 문제를 처리해야합니까?
고맙습니다. 관찰 된 속도의 새로운 값이 0 인 경우 if ([player.currentItem.asset isPlayable])
검사의
대답은 AVAsynchronousKeyValueLoading의 도입에 있습니다 https://developer.apple.com/library/mac/documentation/AVFoundation/Reference/AVAsynchronousKeyValueLoading_Protocol/index.html –