itemFailedToPlayToEnd - MPMoviePlayerController - iOS7

冷暖自知 提交于 2019-12-03 10:45:41
user40910

It would be two issues

  1. Problem with url

    a) If it is fetching from api's you have to write ,[NSUrl urlwithString:"your url string"];

    // your url string does not be youtube url string.

    b) If it is from bundle path : [NSUrl fileWithPath:"Your path"];

  2. Problem with Source type.

    Set scouce type to any one , if it not works set to other type viceversa

    yourPlayerController.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
    

    or

    yourPlayerController.moviePlayer.movieSourceType = MPMovieSourceTypeUnknown;
    

I'm having the same issue on my iOS 7 build. May I ask if you have any white spaces and numbers in your video's URL?

i.e. my url was something like "video title 5.2.5.mov" and when I escaped the string using the NSUTF8StringEncoding, the result was "video%20title%205.2.5.mov" and it didn't work.

I tried changing the movie url to video_title_5_2_5.mov" and it loaded fine

hope this advice helps a little

A tip for those implementing local file caches: include file extensions

I have a local download cache in one of my applications that does not differentiate on filetype [for better or worse], resulting in files without types associated with them. When I serve the file from the server directly into the movie controller, the file plays fine, however when it is stored locally into the path: [AppDocumentsDirectory]/123 (without an extension) it fails to play. When I stored the file as 123.mp4 it succeeded.

I ended up testing the app on an actual ipod - and it worked. The url Im init with the mpmoviecontroller didn't have any spaces that i needed to escape. Hope this helps... the videos dont work on simulator which was throwing me off

I had this same problem and it was fixed by setting

[MPMoviePlayerViewController.moviePlayer setShouldAutoplay:YES]

The problem I was seeing was that the movie player would push onto the navigation controller, but right when it appeared it would disappear and I would get the _itemFailedToPlayToEnd error in the log

I was having the same issue . First check that file from where you want to play that video does exist or not.Then Play . In my case my file was in document directory .so

    BOOL hasVideoFile= [[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@",[self getDocumentDirectory] videoFileName]];
    if (!hasVideoFile) {
        //No video found
        NSLog(@"Video file doesn't exists in this directory");
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!