Iphone ItemFailedToPaytoEnd-MPMoviePlayerController-iOS7
为iOS 7更新我的应用程序时遇到奇怪的问题。对于iOS 6,没有问题,视频总是加载的。然而,这里的情况并非如此 我有一个Iphone ItemFailedToPaytoEnd-MPMoviePlayerController-iOS7,iphone,ios,ios7,mpmovieplayercontroller,Iphone,Ios,Ios7,Mpmovieplayercontroller,为iOS 7更新我的应用程序时遇到奇怪的问题。对于iOS 6,没有问题,视频总是加载的。然而,这里的情况并非如此 我有一个滚动视图,其中显示播放项目——一旦单击播放项目,就会创建一个MPMoviePlayerController,以显示播放列表项目(视频) 以下是我认为引起问题的方法: - (void) play:(NSInteger)itemId withAutostart:(BOOL)autostart { // remember whether it is in fullscreen
滚动视图
,其中显示播放项目
——一旦单击播放项目
,就会创建一个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];
}
奇怪的是,它适用于ios6
,而不适用于ios7
以下是未加载/播放视频时的NSLog错误::CGImageCreate:无效图像大小:0 x 0。
和:\u itemFailedToPlayToEnd:{
种类=1;
新的=2;
old=0;
}
我的iOS 7版本也有同样的问题。请问您的视频URL中是否有空格和数字
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
希望这个建议能对那些实现本地文件缓存的人有所帮助:包括文件扩展名 我的一个应用程序中有一个本地下载缓存,它在文件类型上没有区别(无论是好是坏),导致文件没有与其关联的类型。当我将文件从服务器直接提供到电影控制器中时,文件可以正常播放,但是当文件本地存储到路径中时:
[AppDocumentsDirectory]/123(无扩展名)无法播放。当我将该文件存储为123.mp4时,它成功了。我最终在一台实际的ipod上测试了该应用程序,并且成功了。带有mpmoviecontroller的url Im init没有我需要转义的任何空间。希望这有助于。。。这些视频在模拟器上不起作用,这让我感到厌烦。这可能是两个问题
yourPlayerController.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
或
我也有同样的问题,通过设置
[MPMoviePlayerViewController.moviePlayer setShouldAutoplay:YES]
我看到的问题是,电影播放器会推到导航控制器上,但当它出现时,它就会消失,我会在日志中找到“FailedToPlaytoEnd”错误,我也遇到了同样的问题。 首先检查要播放该视频的文件是否存在,然后播放。 在我的例子中,我的文件在文档目录中
BOOL hasVideoFile= [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@",[self getDocumentDirectory] videoFileName]];
if (!hasVideoFile) {
//No video found
NSLog(@"Video file doesn't exists in this directory");
}
我最终在一台真正的ipad上测试了这个应用程序——瞧,它居然成功了。带有mpmoviecontroller的url Im init没有我需要转义的任何空间。希望这有助于。。。视频不工作的模拟器,这是扔我了我有一个相关的错误。从我的文件名中删除该编号是解决方法。谢谢你的这个想法。我只有在iOs7上遇到了类似的问题。我也遇到了错误-11828。有人找到了解决这个问题的方法吗?你有没有试着听
mpmovieplayerplaybackdidfishnotification
通知?可能吧。这应该是一个评论。
BOOL hasVideoFile= [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@",[self getDocumentDirectory] videoFileName]];
if (!hasVideoFile) {
//No video found
NSLog(@"Video file doesn't exists in this directory");
}