English 中文(简体)
MPMoviePlayerViewController在几秒后停下来
原标题:MPMoviePlayerViewController stops after a few seconds

我有一张照片,我正在把电视直播频道放入一个表格。 我正在使用<条码>MPMoviePlayerViewController。 我确实在我的头盔档案中宣布了我的<代码>MPMoviePlayerViewController,并在我的执行档案中加以综合。

我的看法 DidAppear:

- (void)viewDidAppear:(BOOL)animated   
{
    NSURL *movieURL = [[NSURL alloc]initWithString:@"http://mysuperURL"];
    moviePlayerController = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL];
    [self checkIt];
}

我的检查 其职能

- (void) checkIt {
    if ([[moviePlayerController moviePlayer] loadState] == MPMovieLoadStateUnknown) { // before you wreck yourself
        [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(checkIt) userInfo:nil repeats:NO];
    } else {
        [moviePlayerController setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
        [self presentModalViewController:moviePlayerController animated:YES];
    }
}

www.un.org/Depts/DGACM/index_spanish.htm 然而,在两秒之后的录像冻结和回答的信号。

问题回答

你们应使用MoviePlayer核电灯,而不是用人工方式对目前状态进行投票。

例如,在您的首创守则中有些地方:

[[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(MPMoviePlayerLoadStateDidChange:) 
                                                 name:MPMoviePlayerLoadStateDidChangeNotification 
                                               object:nil];

现执行通知递送人:

- (void)MPMoviePlayerLoadStateDidChange:(NSNotification *)notification
{
    NSLog(@"loadstate change: %Xh", movieController_.loadState);    
}

在您的初创守则中,有一段地方:

[[NSNotificationCenter defaultCenter] removeObserver:self 
                                                    name:MPMoviePlayerLoadStateDidChangeNotification 
                                                  object:nil];

还注意到MPMoviePlayerController装载。 国家是一个蓝图,而且很普遍;你必须掩盖你想要检查的价值。

例:

if ((movieController_.loadState & MPMovieLoadStatePlayable) == MPMovieLoadStatePlayable)
{
    NSLog(@"yay, it became playable");
}

我的知识涉及使用时间,这是冻结的,也需要时间流逝。





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签