Piero
Piero

Reputation: 9273

play iTunes preview video with MPMoviePlayerController

i'm trying to play a video from URL, the video i want play is a iTunes preview video like this: http://a236.v.phobos.apple.com/us/r1000/051/Video/ec/1d/7f/mzm.hwbfvfdq..640x480.h264lc.d2.p.m4v i have tried on the iPhone, and open the player, i see the buffer is loaded, but if i play it i don't see anything, how i can do?...this is the code:

- (void) moviePlayBackDidFinish:(NSNotification*)notification {

MPMoviePlayerController *moviePlayer = [notification object];

[[NSNotificationCenter defaultCenter] removeObserver:self      
                                                name:MPMoviePlayerPlaybackDidFinishNotification
                                              object:moviePlayer];

if ([moviePlayer 
     respondsToSelector:@selector(setFullscreen:animated:)])
{
    [moviePlayer.view removeFromSuperview];
}
[moviePlayer release];
}

- (IBAction)playVideo:(id)sender {

NSURL *url = [NSURL URLWithString:@"http://a236.v.phobos.apple.com/us/r1000/051/Video/ec/1d/7f/mzm.hwbfvfdq..640x480.h264lc.d2.p.m4v"];

MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(moviePlayBackDidFinish:)
                                             name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:moviePlayer];

moviePlayer.controlStyle = MPMovieControlStyleDefault;
moviePlayer.shouldAutoplay = YES;

[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];


}

Upvotes: 0

Views: 1086

Answers (2)

Max B.
Max B.

Reputation: 871

Since you are trying to access a .m4v file from iTunes. The DRM protection is the problem.

EDIT: Your link works in Quicktime, but not in the browser.

Apple does not allow playing DRM protected music or videos from iTunes in the MPMoviePlayerConroller (which includes the previews).

Please also see following link on Stackoverflow

Upvotes: 1

iremk
iremk

Reputation: 677

when i copy&paste the link (http://a236.v.phobos.apple.com/us/r1000/051/Video/ec/1d/7f/mzm.hwbfvfdq..640x480.h264lc.d2.p.m4v) to a browser , i did not see/hear the video/audio also..

first there seems to be more than 1 point between hwbfvfdq and 640x480 , maybe there is some characters you did not copy or did not see.

and also, since this is a url from itunes, they may be a usage of tokens to avoid users to reach videos like this url link permanently.

hope this helps ..

p.s. : have you tried your code with a direct url of a movie you know?

Upvotes: 0

Related Questions