Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/114.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Xcode 5使用MPMoviePlayer播放电影返回SIGABRT_Ios_Xcode_Mpmovieplayercontroller_Sigabrt - Fatal编程技术网

Ios Xcode 5使用MPMoviePlayer播放电影返回SIGABRT

Ios Xcode 5使用MPMoviePlayer播放电影返回SIGABRT,ios,xcode,mpmovieplayercontroller,sigabrt,Ios,Xcode,Mpmovieplayercontroller,Sigabrt,我一直试图通过单击UIButton来播放本地视频文件,并且每次单击模拟器中的按钮时都会返回SIGABRT错误。我试过m4v和mp4文件。下面是我尝试过但仍然返回SIGABRT的最新代码集。这套代码似乎适用于YouTube上的每个人,但在我运行应用程序时却不起作用。是的,我确实导入了MediaPlayer框架。Xcode 5.1.1有什么不同吗 // ViewController.h #import <UIKit/UIKit.h> #import <MediaPlayer/Me

我一直试图通过单击UIButton来播放本地视频文件,并且每次单击模拟器中的按钮时都会返回SIGABRT错误。我试过m4v和mp4文件。下面是我尝试过但仍然返回SIGABRT的最新代码集。这套代码似乎适用于YouTube上的每个人,但在我运行应用程序时却不起作用。是的,我确实导入了MediaPlayer框架。Xcode 5.1.1有什么不同吗

//  ViewController.h
#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>

@interface ViewController : UIViewController

- (IBAction)playButton:(id)sender;

@end


//  ViewController.m
#import "ViewController.h"

@interface ViewController ()
@end
@implementation ViewController

- (IBAction)playButton:(id)sender
{
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"movie1" ofType:@"m4v"]];

MPMoviePlayerViewController *playerController = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
[self presentMoviePlayerViewControllerAnimated:playerController];
playerController.moviePlayer.movieSourceType = MPMovieSourceTypeFile;

[playerController.moviePlayer play];
playerController = nil;
}
//ViewController.h
#进口
#进口
@界面ViewController:UIViewController
-(iAction)播放按钮:(id)发送方;
@结束
//ViewController.m
#导入“ViewController.h”
@界面视图控制器()
@结束
@实现视图控制器
-(iAction)播放按钮:(id)发送方
{
NSURL*url=[NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@“m4v”类型的“movie1”;
mpmovieplayervewcontroller*playerController=[[mpmovieplayervewcontroller alloc]initWithContentURL:url];
[自我呈现电影播放服务控制器激活:播放控制器];
playerController.moviePlayer.movieSourceType=mpmoviesourcetype文件;
[playerController.moviePlayer play];
playerController=零;
}
这项工作:

//ViewController.h
#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>

@interface ViewController : UIViewController

- (IBAction)playButton;
@property MPMoviePlayerController *mpc;

@end

//ViewController.m
#import "ViewController.h"
@interface ViewController ()

@end

@implementation ViewController
@synthesize mpc;

- (IBAction)playButton
{
NSString *bundle = [[NSBundle mainBundle] pathForResource:@"videofile" ofType:@"mov"];
NSURL *url = [NSURL fileURLWithPath:bundle];
mpc = [[MPMoviePlayerController alloc] initWithContentURL:url];

[mpc setMovieSourceType:MPMovieSourceTypeFile];

[[self view]addSubview:mpc.view];
[mpc setFullscreen:YES];

[mpc play];
}

@end
//ViewController.h
#进口
#进口
@界面ViewController:UIViewController
-(iAction)播放按钮;
@财产MPMoviePlayerController*mpc;
@结束
//ViewController.m
#导入“ViewController.h”
@界面视图控制器()
@结束
@实现视图控制器
@合成mpc;
-(iAction)播放按钮
{
NSString*bundle=[[NSBundle mainBundle]路径资源:@“videofile”类型:@“mov”];
NSURL*url=[NSURL fileURLWithPath:bundle];
mpc=[[MPMoviePlayerController alloc]initWithContentURL:url];
[mpc setMovieSourceType:MPMovieSourceType文件];
[[self view]addSubview:mpc.view];
[mpc设置全屏:是];
[mpc播放];
}
@结束

我认为您的nib或故事板检查是否所有连接都正确时出现了错误(IBOutlets和IBActions)。检查fileURLWithPath:它也可能返回nil,也可以尝试用FileUrlWithStringGIF替换它。如果您在控制台中遇到任何特定错误,请使用这些错误更新问题。并且您使用playerController=nil;。libc++abi.dylib:以NSException(lldb)类型的未捕获异常终止是否意味着什么?好的,我现在可以在将fileWithURLPath更改为URLWithString后让视频播放器显示,但它将继续说永远加载。我也有过这样的操作,视频播放器将短暂显示,然后消失并给出错误“_itemFailedToPlayToEnd:{kind=1;new=2;old=0;}”