RollRoll
RollRoll

Reputation: 8462

Why doesn't this code work streaming a song using MPMoviePlayerController

I'm having a hard time trying to figure this out, any suggestion is welcome:

NSURL *songUrl = [NSURL URLWithString:@"http://a1804.phobos.apple.com/us/r1000/064/Music/v4/9b/b3/c7/9bb3c7dc-a06f-f18c-3e41-2ce1e36f73b4/mzaf_7432104896053262141.aac.m4a"];

MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:songUrl];

[[NSNotificationCenter defaultCenter] addObserver:self

                                         selector:@selector(moviePlayBackDidFinish:)

                                             name:MPMoviePlayerPlaybackDidFinishNotification

                                           object:nil];



[mp setControlStyle:MPMovieControlStyleFullscreen];

[mp setMovieSourceType:MPMovieSourceTypeStreaming];

[mp setFullscreen:YES];



[self.view addSubview:[mp view]];



[mp prepareToPlay];

[mp play];

Upvotes: 1

Views: 137

Answers (2)

aadarshsg
aadarshsg

Reputation: 2089

Try using MPMoviePlayerViewController instead of MPMoviePlayerController.

Upvotes: 1

Michael Dautermann
Michael Dautermann

Reputation: 89509

It might be more useful if you said what your problem was in your original question.

But I compiled your code into a test app on my side and found the problem pretty quick (especially after looking at this related question and it's answers).

To solve the problem I think you are having, add this line of code somewhere before adding the Movie Player subview to the parent view:

[mp.view setFrame: self.view.bounds];

And the controller should appear in proper full screen size.

Upvotes: 0

Related Questions