Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jnoxx

macrumors 65816
Original poster
Dec 29, 2010
1,343
0
Aartselaar // Antwerp // Belgium
Hi Guys,

I'm being baffled by this issue (ARGHHH).
I was trying to maintain multiple video's on screen until I noticed that MPMoviePlayerViewController doesn't support more then 1 active playing video. So they told me I had to use AVPlayer.
Tbh, I can't really get it, I'm really confused. I googled around and came on a blog (http://www.sdkboy.com/?p=66), which explained, but I didn't like his way of taking on things, so I found something else called
Code:
http://developer.apple.com/library/ios/#samplecode/AVPlayerDemo/Listings/Classes_AVPlayerDemoPlaybackView_m.html
but i'm seriously baffled by this one. I have 1 newly created project where I added an Helper class to give me back one of these views like this
Code:
+ (AVPlayerDemoPlaybackView *)videoWithPathName:(NSString *)videoName {
    NSBundle *bundle = [NSBundle mainBundle];
    NSString *moviePath = [bundle pathForResource:videoName ofType:@"mp4"];
    NSURL *movieURL = [NSURL fileURLWithPath:moviePath];
    
    AVPlayer *player = [AVPlayer playerWithURL:movieURL];
    
    AVPlayerDemoPlaybackView *movieController = [[AVPlayerDemoPlaybackView alloc] init];
    [movieController setPlayer:player];
    //player.actionAtItemEnd = AVPlayerActionAtItemEndNone;
    
    return movieController;
}

Which works.

I'm currently working on a quite memory intense project where I need this, where I do the same.

Code:
AVPlayerDemoPlaybackView *layerView = [LayerDataHelper videoWithPathName:layer.name];
    [layerView setFrame:self.layerContainer.bounds];

    [layerView.player play];
    NSLog(@"layerView.player: %@", layerView.player);
    [self.layerContainer insertSubview:layerView atIndex:index+1];

It adds it on the view, and I see the first frame, but it just doesn't play..
Anybody has any experience on this?
(the layerview.player gives an existing pointer direction so it's not null).

PS: No one ever worked with multiple video instances then?
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.