Получение сигнала SIGABRT при попытке воспроизвести видео (Objective-C) - PullRequest
0 голосов
/ 25 марта 2012

Когда я пытаюсь загрузить видео, я получаю SIGABRT. Ниже мой код. Если бы кто-нибудь мог сообщить мне, почему я получаю эту ошибку, это было бы здорово. Сигнал генерируется для строки: theMovie = [[MPMoviePlayerController alloc] initWithContentURL: [NSURL fileURLWithPath: url]];

Два вопроса: что не так с моим кодом? и что обычно означает SIGABRT?

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

# импорт

@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

1 Ответ

0 голосов
/ 25 марта 2012

Я обнаружил, что ошибки Sigabrt обычно появляются, когда вы пытаетесь получить доступ к объекту, которого нет или является пустой ссылкой.Так что, возможно, ваша проблема в том, что файл не существует, или, возможно, вы потеряли ссылку на ваш файл или ваш объект видеоплеера где-то.

Peter

...