Wednesday, April 18, 2012

MPMoviePlayerViewController can not play mp4 file

I'm working on a test application that will run an mp4 file from internet.
code is :



-(IBAction)playRemoteVideo
{

NSString *mp4File = @"http://archive.org/download/Pbtestfilemp4videotestmp4/video_test_512kb.mp4";

MPMoviePlayerViewController *playerController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:mp4File]];
[self presentMoviePlayerViewControllerAnimated:playerController];
playerController.moviePlayer.movieSourceType=MPMovieSourceTypeStreaming;

[playerController.moviePlayer play];
[playerController release];
playerController=nil;
}


When I run the application and played the video the player tries to load the video for a while but after I got this exception on console



2012-04-18 22:45:11.309 VideoPlayer[891:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'An AVPlayerItem can occupy only one position in a player's queue at a time.'
*** First throw call stack:
(0x1df1052 0x1333d0a 0x27cfb31 0x27cbb2a 0x27e45cc 0x103b73 0xd4e6a 0x2ff2445 0x2ff44f0 0x1d28833 0x1d27db4 0x1d27ccb 0x16d8879 0x16d893e 0x24ea9b 0x1d12 0x1c85)
terminate called throwing an exception(gdb)


If I execute the same code with an m3u8 file , for instance;



http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8


I can get the video running but same does not work for mp4 file.



Do you have any idea why I got this exception and what's wrong with my code?



I run the application on Iphone simulator and I have XCode 4.2
Best Regards
Tugrul





No comments:

Post a Comment