0

ビデオをロードしようとすると、SIGABRTがスローされます。以下は私のコードです。誰かが私になぜこのエラーが出るのかを教えてもらえれば、それは素晴らしいことだろう。シグナルは次の行にスローされます。theMovie = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]];ビデオを再生しようとしたときにSIGABRTシグナルを取得する(Objective-C)

2つの質問:私のコードに何が間違っていますか? SIGABRTは通常何を意味しますか?

#import "Video.h" 
#import "MyManager.h" 

私はあなたが存在しないか、null参照であるオブジェクトにアクセスしようとすると、SIGABRTエラーは通常、表示されていることを見つけるの#import

@implementation Video 

MPMoviePlayerController* theMovie; 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) { 

    } 
    return self; 
} 

- (void)dealloc{ 
    [theMovie release]; 
    [super dealloc]; 
} 

- (void)didReceiveMemoryWarning 
{ 
    // Releases the view if it doesn't have a superview. 
    [super didReceiveMemoryWarning]; 

    // Release any cached data, images, etc that aren't in use. 
} 

#pragma mark - View lifecycle 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    MyManager *sharedManager = [MyManager sharedManager]; 
    NSString *tempName = sharedManager.vidName; 
    NSString *url = [[NSBundle mainBundle] pathForResource:sharedManager.vidName ofType:@"mp4"]; 
    theMovie = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]]; 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinishedCallBack:) name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie]; 
    theMovie.scalingMode = MPMovieScalingModeAspectFit; 
    [theMovie.view setFrame:self.view.bounds]; 
    [self.view addSubview:theMovie.view]; 
    [theMovie play]; 

    } 

-(void)movieFinishedCallBack:(NSNotification *) aNotification{ 
    theMovie = [aNotification object]; 
    [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie]; 
    [theMovie.view removeFromSuperview]; 
    [theMovie pause]; 
    [theMovie stop]; 
} 

-(void) viewWillDisappear:(BOOL)animated{ 
    [theMovie pause]; // assume myMoviePlayer is an instance variable 
    [theMovie stop]; 
    theMovie = nil; 
    [theMovie release]; 
} 

- (void)viewDidUnload 
{ 
    [theMovie pause]; // assume myMoviePlayer is an instance variable 
    [theMovie stop]; 
    theMovie = nil; 
    [theMovie release]; 

    [super viewDidUnload]; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // Return YES for supported orientations 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

@end 
+0

クラッシュレポートの表示方法はわかりますか?あなたにいくつかの手がかりを与えることができるかもしれないことを確認する。それは未知の例外によって引き起こされる可能性があります – tams

+0

@tams私はiPhoneの開発にはとても新しいので、これはObjective-cで初めてのプロジェクトです。クラッシュレポートを表示する方法がわかりません。どのように私はそれに得ることができますか?出力ログにはそれだけがありますか?ログには、「NSException」のインスタンスをスローした後に呼び出されるterminateがあります。 –

+0

OK、新しい場合は、ビューをデバッグして起動することができます。メソッドの先頭にブレークポイントを置き、コードをステップ実行します。すべての変数が正しく、文字列が正しく設定されていることを確認してください。恐らく問題はそこにある。 – tams

答えて

0

。 あなたの問題は、ファイルが存在しないか、ファイルやビデオプレイヤーオブジェクトへの参照がどこかで失われていることです。

Peter

関連する問題