开发者

i have two mpmovieplayercontrollers and two separate subviews that they utilze... except that only one video will play at a time

I would like to have both movies playing at once in their two separate sub views. They are both accessing different media.

this is on an ipad with a superview and two little views 320x240 right by eachother on the xib.

-(IBAction)playLeft:(id)sender{
if ([self.playerRight playbackState] == MPMoviePlaybackStatePlaying);
[self.playerRight stop];

[self.playerLeft play];
}

-(IBAction)playRight:(id)sender{
if ([self.playerLeft playbackState] == MPMoviePlaybackStatePlaying);
[self.playerLeft stop];

[self.playerRight play];
}



- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor viewFlipsideBackgroundColor];

self.playerLeft = [[MPMoviePlayerController alloc] init];
self.playerLeft.contentURL = [self movieURL];

NSLog(@"self.playerLeft %@", self.playerLeft);


self.playerRight = [[MPMoviePlayerController alloc] init];
self.playerRight.contentURL = [self movieURL2];

NSLog(@"self.playerRight %@", self.playerRight);



// START_HIGHLIGHT
self.playerLeft.view.frame = self.leftView.bounds;
self.playerLeft.view.autoresizingMask = 
UIViewAutoresizingFlexibleWidth |
UIViewAutore开发者_开发百科sizingFlexibleHeight;

self.playerRight.view.frame = self.rightView.bounds;
self.playerRight.view.autoresizingMask = 
UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleHeight;

[self.rightView addSubview:playerRight.view];
[self.leftView addSubview:playerLeft.view];


//[self.playerRight play];

//[self.playerLeft play];


//[self clickedOpenMovie:nil];

}

-(NSURL *)movieURL
{
NSBundle *bundle = [NSBundle mainBundle];
NSString *moviePath = 
[bundle 
      pathForResource:@"720p5994-prores-hq_iPhone_320x240 two" 
 ofType:@"m4v"];
//NSString *moviePath = [NSString stringWithFormat:@"http://localhost:1935/live/aStream/playlist.m3u8"];

if (moviePath) {
return [NSURL fileURLWithPath:moviePath];
//return [NSURL URLWithString:moviePath];

} else {
return nil;
}
}

-(NSURL *)movieURL2
{
NSBundle *bundle = [NSBundle mainBundle];
NSString *moviePath = 
[bundle 
pathForResource:@"720p5994-prores-hq_iPhone_320x240" 
ofType:@"m4v"];
if (moviePath) {
return [NSURL fileURLWithPath:moviePath];
} else {
return nil;
}
}


so the problem is that somewhere in the background MPMoviePlayerController responds to notifications and turns itself off if another MPMoviewPlayerController broadcasts that its going to start. Thus one can not have multiple MPMoviePlayerControllers playing at the same time.

you can see this by printing out the MPMoviePlayerPlaybackStateDidChangeNotification

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜