0

Before start my task i want to know the possibilities for playing 2 videos simultaneously(together) by using url.

Code that i'm tried for play the video in a partial screen:

player = [[MPMoviePlayerController alloc] initWithContentURL:[self movieURL]];
player.view.frame = CGRectMake(100, 150, 250, 300);
[self.view addSubview:player.view];
[[NSNotificationCenter defaultCenter]addObserver:self
                                        selector:@selector(movieFinishedCallback:)
                                            name:MPMoviePlayerPlaybackDidFinishNotification
                                          object:player];
[player play];

Error: error:request for member 'view' in somthing not a structure or union

Anyone Helpme...

Rais Alam
  • 6,970
  • 12
  • 53
  • 84
kanmani
  • 671
  • 1
  • 10
  • 28
  • Have you tried making two instances of MPMoviePlayerController and then adding their views side by side in a view hierarchy? – Carl Veazey Feb 18 '11 at 05:49
  • @Carl Veazey:I'm new for this kind of video playing task.please explain me as clear as possible.How can i adding the views side by side in a view hierarchy.Thank you for your quick response... – kanmani Feb 18 '11 at 05:54
  • Create an MPMoviePlayerController, then set its view's frame to an appropriate size and position. Then do the same with a different frame. Add both views to your main view, then call play on the controllers. – Carl Veazey Feb 18 '11 at 06:10
  • I just tried it in a quick sample app. It doesn't appear to work, I'm not sure if you can have more than one MPMoviePlayerController allocated at the same time or not. – Carl Veazey Feb 18 '11 at 06:18
  • @Carl Veazey:I have inculde some code in my question for playing the video in a partial(small screen) view and i got some error in that.please refer my question.Thank you – kanmani Feb 18 '11 at 06:27
  • Is it when you access self.view or player.view ? – Carl Veazey Feb 18 '11 at 06:34
  • @Carl Veazey:When i try to access player.view – kanmani Feb 18 '11 at 06:49
  • What version of iOS are you developing for? Also, did you import MediaPlayer.h ? – Carl Veazey Feb 18 '11 at 06:53
  • @Carl Veazey:using iOS 3.0.I have import the MediaPlayer.h like this..,#import and also include the framework MediaPlayer.Framework. – kanmani Feb 18 '11 at 07:00
  • You can only do this on iOS 3.2 and above. – Carl Veazey Feb 18 '11 at 07:10
  • @Carl Veazey:ok..now i'm going to check this with iOS 3.2 – kanmani Feb 18 '11 at 07:12
  • As @rgeorge said, you won't be able to run it because of its one stream at a time limit. – Carl Veazey Feb 18 '11 at 07:13
  • @Carl Veazey:Yeah..it's perfectly played with parial screen when i'm using iOS 4.0 – kanmani Feb 18 '11 at 07:21
  • @Carl Veazey:Thank you Carl.. – kanmani Feb 18 '11 at 07:42

2 Answers2

3

Not normally. MPMoviePlayerController works by connecting to a separate server process, which does the actual video decompression. It only decompresses one stream at a time, so only one movie view can have playing content at once.

Your best bet is to use your favorite video editing software to combine both movies into a single movie, side by side. Obviously this is no good if you want to play/pause/rewind them separately. Or, if one of the movies is very small, convert it to still frames and use UIImageView's multi-image animation feature. Playing h.264 from a remote URL is right out, though.

[Edited to add:]

This was true for iOS 3.x, but iOS 4 and later have video support in AVFoundation, specifically, the AVPlayer and AVPlayerLayer classes. If you use them to construct movie views, you can have more than one going at once, independently. What you don't get are the stock MPMoviePlayerController transport controls (play/pause/scrub bar); with AVFoundation you have to roll your own if you want something similar.

rgeorge
  • 7,385
  • 2
  • 31
  • 41
  • Referring to your edit - Have you tried to actually play two remote videos at the very same time using AVFoundation? – Till Mar 31 '12 at 23:44
0

Yeah sure, you can play two videos simultaneaously, even on each other

Checkout this url & get an idea.

Niru Mukund Shah
  • 4,637
  • 2
  • 20
  • 34