【发布时间】:2013-10-06 22:28:41
【问题描述】:
在为iOS 7 更新我的应用程序时遇到了一个奇怪的问题。对于iOS 6,没有问题,视频总是被加载。但是这里不是这样。
我有一个scrollview,它显示playlistItems - 一旦你点击playlistItem,就会创建一个MPMoviePlayerController 来显示播放列表项(视频)。
这是我认为会导致问题的方法:
- (void) play:(NSInteger)itemId withAutostart:(BOOL)autostart {
// remember whether it is in fullscreen or not to restore for the next playlist item
self.playerInFullscreen = self.player.isFullscreen;
if (player != nil) {
[self.player setFullscreen:NO animated:NO];
[self stopListeningPlaybackFinishedEvents];
[player stop];
[self startListeningPlaybackFinishedEvents];
}
PlaylistItem * pi = [dbHelper getPlaylistItem:itemId];
NSURL *movieURL = [pi getMovieUrl];
if (DELEGATE.useSSL) {
NSURLCredential *credential = [[NSURLCredential alloc]
initWithUser: DELEGATE.username
password: DELEGATE.password
persistence: NSURLCredentialPersistenceForSession];
NSURLProtectionSpace *protectionSpace = [[NSURLProtectionSpace alloc]
initWithHost: [movieURL host]
port: 80
protocol: [movieURL scheme]
realm: [movieURL host]
authenticationMethod: NSURLAuthenticationMethodHTTPBasic];
[[NSURLCredentialStorage sharedCredentialStorage]
setDefaultCredential: credential
forProtectionSpace: protectionSpace];
[protectionSpace release];
[credential release];
}
MPMoviePlayerController * temp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
[temp prepareToPlay];
self.player = temp;
[temp release];
player.shouldAutoplay = autostart;
player.view.frame = movieViewContainer.bounds;
[movieViewContainer addSubview:player.view];
NSLog(@"movie added to subview");
[player setFullscreen:self.playerInFullscreen animated:NO];
[self.view setNeedsDisplay];
}
电影正在加载到MovieContainerView。
- (void)playlistItemSelected:(NSInteger)itemId withAutostart:(BOOL) autostart {
for(UIView *subview in [thumbsScrollView subviews]) {
if ([subview isKindOfClass:[PlaylistItemView class]] == YES ) {
PlaylistItemView *piv = ((PlaylistItemView *) subview);
[piv setCurrent: piv.playlistItem._id == itemId];
if (piv.playlistItem._id == itemId) {
[self ensurePlaylistItemViewVisible:piv];
}
}
}
[[movieViewContainer subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
self.currentPlaylistItem = [dbHelper getPlaylistItem:itemId];
[self updateMetadataArea:itemId];
if ([_currentPlaylistItem.type isEqual:VIDEO_TYPE]) {
self.zoomButtonOut.hidden = YES;
self.zoomButtonIn.hidden = YES;
[self play:itemId withAutostart:autostart];
}
else {
[self.player pause];
_zoomButtonIn.alpha = ZOOM_BUTTON_ALPHA;
_zoomButtonOut.alpha = ZOOM_BUTTON_ALPHA;
[self showPDFandImage:_currentPlaylistItem];
}
[self scrollViewDidEndDecelerating:nil];
}
奇怪的是,这适用于iOS 6,但不适用于iOS 7
以下是视频无法加载/播放时的 NSLog 错误:<Error>: CGImageCreate: invalid image size: 0 x 0. 和:_itemFailedToPlayToEnd: {
kind = 1;
new = 2;
old = 0;
}
【问题讨论】:
-
我只在 iOs7 上遇到了类似的问题,我也收到错误 -11828 有人找到解决方案了吗?
-
您是否尝试收听
MPMoviePlayerPlaybackDidFinishNotification通知?可能是contains an error object.
标签: iphone ios ios7 mpmovieplayercontroller