尝试播放视频时收到SIGABRT信号(Objective-C) [英] Getting SIGABRT signal when I try to play a video (Objective-C)

查看:124
本文介绍了尝试播放视频时收到SIGABRT信号(Objective-C)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试加载视频时,我抛出了SIGABRT.下面是我的代码.如果有人可以让我知道为什么我会收到此错误,那太好了.正在向该行抛出信号:theMovie = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]];

When I try to load a video, I'm getting a SIGABRT thrown. Below is my code. If anybody could let me know why I'm getting this error, that would be great. The signal is being thrown for the line: theMovie = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]];

两个问题:我的代码有什么问题? SIGABRT通常是什么意思?

Two questions: what is wrong with my code? and what does SIGABRT usually mean?

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

#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

推荐答案

我发现,当您尝试访问不存在或具有空引用的对象时,通常会出现Sigabrt错误. 因此,也许您的问题是该文件不存在,或者您丢失了对文件或视频播放器对象的引用.

I find that Sigabrt errors usually appear when you try to access an object that is not there or is a null reference. So maybe your problem is that the file does not exist or maybe you have lost a reference to your file or your videoplayer object somewhere.

彼得

这篇关于尝试播放视频时收到SIGABRT信号(Objective-C)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆