Oxe*_*xen 14 iphone mpmovieplayercontroller ios ios7
在更新我的应用时遇到一个奇怪的问题iOS 7.因为iOS 6,没有问题,视频总是被加载.然而,这不是这种情况.
我有一个scrollview显示playlistItems- 一旦你点击它playlistItem,MPMoviePlayerController创建一个a 来显示播放列表项目(视频).
以下是我认为导致问题的方法:
- (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];
}
Run Code Online (Sandbox Code Playgroud)
这部电影正在加载到电影中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];
}
Run Code Online (Sandbox Code Playgroud)
奇怪的是,这适用于iOS 6但不是iOS 7
以下是视频无法加载/播放时的NSLog错误:<Error>: CGImageCreate: invalid image size: 0 x 0. 和:_itemFailedToPlayToEnd: {
kind = 1;
new = 2;
old = 0;
}
我的 iOS 7 版本也遇到同样的问题。请问您的视频网址中是否有空格和数字?
i.e. my url was something like "video title 5.2.5.mov" and when I escaped the string using the NSUTF8StringEncoding, the result was "video%20title%205.2.5.mov" and it didn't work.
I tried changing the movie url to video_title_5_2_5.mov" and it loaded fine
Run Code Online (Sandbox Code Playgroud)
希望这个建议有一点帮助
| 归档时间: |
|
| 查看次数: |
10700 次 |
| 最近记录: |