2
votes

I try to integrate a Youtube player inline to a UIWebview. I use the Javascript/iFrame API with the Player API.

In general, the player works ok. But there are some cases where the video does not start and I get a message "Video is currently unavailable".

I have tried to clear the cache of the uiwebview programmtically using this code:

 [[NSURLCache sharedURLCache] removeAllCachedResponses];

I also cleared the cache of the Safari in case this was the problem, but no luck.

An example for a video is the following: http://www.youtube.com/embed/z-6cCmxaGoQ?enablejsapi=1&rel=0&playsinline=1&showinfo=1&controls=0&vq=hd720

Any ideas for this random & strange behaviour?

2

2 Answers

2
votes

I used the code from here https://github.com/youtube/youtube-ios-player-helper/. However you need to add a param to resolve the problem. Please find the example below.

let vars = ["origin": "http://www.youtube.com"]
videoView.load(withVideoId: "YourVideoID", playerVars: vars)
-2
votes

Some videos and channels have privacy issues and they dont play from any other place, except from youtube... Step 1:- check url is correct which youare trying to play step 2:- check videoid is parsed properly step 3:- check webview has loaded the content step 4:- video doesn't has privacy issues It shud work then, mine is working