iOS YTPlayerView HTTP Load Failed Error Code: -999

Donghyun Kim
Sep 7, 2018 · 1 min read

I was building an iOS application with YouTube-Player-iOS-Helper cocoapod library, and I kept getting this error, HTTP load failed (error code: -999).

I searched around for a solution, but all I found was setting the flag, NSAllowsArbitraryLoads to true. Although it seemed to be the right answer, this alone did not solve my problem.

Then I found out from the official Google developers website the below:

  • Reuse your existing, loaded YTPlayerView instances when possible. When a video needs to be changed in a View, don't create a new UIView instance or a new YTPlayerView instance, and don't call either loadVideoId: or loadPlaylistId:. Instead, use the the cueVideoById:startSeconds:suggestedQuality: family of functions, which do not reload the UIWebView. There is a noticeable delay when loading the entire iframe player.

So I made a static YTPlayerView and loaded a video using loadVideoId:at first. All next videos were loaded using cueVideoById:startSeconds:suggestedQuality:. Doing so solved my problem.


Donghyun Kim

Written by

Software Developer

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade