-1

视频排列整齐。我想播放那些视频。

意味着视频在服务器中。视频以阵列形式出现。我从如何播放视频的字典中存储了数组 ia 字典

下面的代码是对是错,如果错了,请告诉我正确的一个

enter code here NSMutableDictionary *dict;


dict =[Videoarray objectAtIndex:0];
NSURL *Movie = [[NSURL alloc] initWithString:[dict valueForKey:@"url"]];
MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:Movie];
theMovie.scalingMode = MPMovieScalingModeAspectFill;
[theMovie play];
MPMoviePlayerController *movie = [[MPMoviePlayerController alloc] initWithContentURL:Movie];
movie.view.frame = CGRectMake(5,5,310, 165);
movie.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight |
UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | 
UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
[scroll addSubview:movie.view];
[movie play];
4

1 回答 1

2

这是连续播放一系列视频的非常粗略的代码:

-(void)viewDidLoad { 
     [self setUpPlayer];
}

-(void)setUpPlayer {
   if(i <= [videoArray count]) {
        player = [[MPMoviePlayerController alloc] initWithContentURL:[videoArray objectAtIndex:i]];
        i++; //use a static integer outside these functions as an index
        [NSNotificationCenter defaultCenter]addObserver:self selector:@selector(movieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:player];
        [player play];
    }
}


- (void) movieFinishedCallback:(NSNotification*) aNotification {
    player = [aNotification object];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:player];    
    [self setUpPlayer];
 }
于 2012-07-09T19:31:23.227 回答