Search code examples
iosyoutubempmovieplayercontrollermpmovieplayer

MPMoviePlayerController Seeing Double


Certain streamed videos from YouTube display squashed and double in MPMoviePlayer as shown in the following screen shot, and other videos produced at the same time and hosted in the same way work fine in the same view. If I go to the YouTube url directly in safari, it sometimes works fine and sometimes presents the exact same issue. One thing I notice in the failing urls is that they specify algorithm=throttle-factor, but I can't seem to edit the YouTube embedded url without breaking it. How can I fix this?

enter image description here


Solution

  • I was using the HCYouTubeParser library (https://github.com/hellozimi/HCYoutubeParser), and it was returning two urls for each size. For some videos, it had one url for the medium size contain 'algorithm=throttle-factor' and another one that did not. Adding the following code inside HCYoutubeParser.m h264videosWithYoutubeURL: makes sure that only un-throttled video urls are outputted.

    BOOL throttled = [url rangeOfString:@"algorithm=throttle-factor"].location != NSNotFound;
    
    if(!throttled)
        [videoDictionary setObject:url forKey:quality];
    

    This works, but since I don't know why these videos fail or what the ramifications are, I have not submitted the change to hellozimi.