Re: MPMoviePlayerController setContentURL twice
Re: MPMoviePlayerController setContentURL twice
- Subject: Re: MPMoviePlayerController setContentURL twice
- From: Heath Borders <email@hidden>
- Date: Tue, 22 Mar 2011 09:01:38 -0500
I was able to replicate my issue. In my original code, I was only
allowing the movie to be played with the embedded controls. When I
set the contentURL a second time, my embedded controls were not
showing, so I couldn't play the movie again. As I mentioned
previously, Matt's code worked great. However, I can replicate my
issue by removing line 4 below.
1 - (IBAction)play1:(id)sender { // button 1
2 [self.thePlayer setContentURL: [[NSBundle mainBundle]
3 URLForResource:@"blend1" withExtension:@"mp4"]];
4 [self.thePlayer play];
5 }
I only want to control the movie from the embedded controls, so I
don't want to programmatically play it. In the MPMediaPlayback
protocol, there is a prepareToPlay method, which must always be called
before the movie starts playing, and which is called if needed by
play.
So, replacing line 4 with
[self.thePlayer prepareToPlay];
makes my code work.
Thanks again for your help, Matt!
-Heath Borders
email@hidden
Twitter: heathborders
http://heath-tech.blogspot.com
On Tue, Mar 22, 2011 at 8:30 AM, Heath Borders <email@hidden> wrote:
> Your code worked! Thanks! The main difference between our snippets
> was that you added the MPMoviePlayerController's view directly to the
> UIViewController's view rather than putting it in a holder view (which
> I doubt would matter) and that you aren't using the embedded controls.
> I'll post back when I figure out what went wrong.
>
> -Heath Borders
> email@hidden
> Twitter: heathborders
> http://heath-tech.blogspot.com
>
>
>
> On Mon, Mar 21, 2011 at 11:50 PM, Matt Neuburg <email@hidden> wrote:
>> On Mon, 21 Mar 2011 22:59:04 -0500, Heath Borders <email@hidden> said:
>>>That's exactly what I did. I have a brand new project with just a
>>>ViewController with 3 views
>>>
>>>[SNIP ridiculous quantities of code]
>>
>> I can't read that. And it isn't what I suggested you do. I said make a *minimal* project. Enough to prove to yourself that setting the contentURL works. And no more than that! Here's my code; this is what I mean when I say "minimal" and "simple" and stuff like that:
>>
>> - (void)viewDidLoad {
>> [super viewDidLoad];
>> MPMoviePlayerController *player = [[MPMoviePlayerController alloc] init];
>> player.shouldAutoplay = NO;
>> player.controlStyle = MPMovieControlStyleNone;
>> [player.view setFrame: CGRectMake(0,0,200,150)];
>> [self.view addSubview: player.view];
>> self.thePlayer = player;
>> [player release];
>>
>> }
>> - (IBAction)play1:(id)sender { // button 1
>> [self.thePlayer setContentURL: [[NSBundle mainBundle]
>> URLForResource:@"blend1" withExtension:@"mp4"]];
>> [self.thePlayer play];
>> }
>>
>> - (IBAction)play2:(id)sender { // button 2
>> [self.thePlayer setContentURL: [[NSBundle mainBundle]
>> URLForResource:@"xbox" withExtension:@"mp4"]];
>> [self.thePlayer play];
>> }
>>
>> That's all. It works. So then you build up from there towards what you *really* want to do. When it stops working, that's when you broke it. m.
>>
>>
>> --
>> matt neuburg, phd = email@hidden, <http://www.apeth.net/matt/>
>> A fool + a tool + an autorelease pool = cool!
>> Programming iOS 4!
>> http://www.apeth.net/matt/default.html#iosbook
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden