ios - MPMoviePlayerController can't play local file with error _itemFailedToPlayToEnd -
I have a local iPhone compatible MP4 video (I have changed the video for the iPhone, and I have uploaded Tested for a web server and putting its URL in Mobile Safari, it plays perfectly) that I want to use the Here's my code: When I try to run simulator (both 6.1 and 7.1), it displays a black screen in the frame (if there is a fullscreen When I try to directly stream the same video file from the web, it works perfectly: I have tried different video files but the result is the same. What am i doing wrong I had the same problem, but it was multi-layered in me case. MPMoviePlayerController
NSString * filePath = [[NSBundle mainBundle] pathForResource: @ "Welcome" type: @ "MP4"]; NSURL * fileURL = [NSURL URLWithString: filePath]; PlayerController = [[MP3 MPV Player Controller Alok] initWithContentURL: fileURL]; PlayerController.movieSourceType = MPMovieSourceTypeFile; PlayerController.backgroundView.backgroundColor = [UIColor whiteColor]; PlayerController.view.translatesAutoresizingMaskIntoConstraints = Yes; PlayerController.scalingMode = MPVsklingModSpeechFile; //[playerController.view setFrame: moviePlayerContainerView.frame]; [PlayerController.viewSet Frame: CGRactMake (0, 0, 200, 200)]; [See MoviePlayer ContributorAubview: Player Controller.View]; PlayerController.contentURL = fileURL; PlayerController.fullscreen = Yes; [For player controller preparation]; [Player controller game];
file URL indicates a valid file:
(lldb) fileURL / var / mobile / applications / 73C97CC9-731E-4446-A53C-2A8CA30A2393 / Tanisalim.app / Welcome.mp4 (lldb) p (bool) [[NSFileManager defaultManager] fileExistsAtPath: filePath isDirectory: NO] (bool) $ 0 = yes
not ) or a movie player opens the view controller Is and remains forever "Loading ...". When I run on the device (iOS 7.1), the behavior is similar, but I'm getting this error on the console:
_itemFailedToPlayToEnd: {kind = 1; New = 2; Old = 0; }
// playerController .contentURL = fileURL; PlayerController.contentURL = [NSURL URLWithString: @ "http://mywebsite.com/Welcome.mp4"];
-fileURLthethath: no more
-URLWithString: to create your own URL, as opposed to @tagya 22 has been mentioned. It seems that many people have a job, but I was already using a file URL, so something was missing.
MPMoviePlayerController A solution that does not like files without extension If you need to store files without any extensions, then create a temporary symlink for the actual file and instead of the "real" file that symlink Give file code to
MPMoviePlayerController .
Creating a symlink in the actual video file
NSError * error; NSFileManager * manager = [NSFileManager defaultManager]; [Manager creates symbolic link at url: linkpath with distinction URL: realfile path error: & amp; Error];
Comments
Post a Comment