Display youtube video that contains content protected by copyright - ios

I am making a scroll view in which there are multiple instances of UIWebView, each with a youtube video that user can tap and watch. I tried multiple approaches how to this (I mean, what to put in UIWebView), the one that worked best was from https://developers.google.com/youtube/iframe_api_reference#Loading_a_Video_Player
However, I have a video that doesn't play, instead it displays "This video contains content from SME. It is restricted from playback on certain sites" (it worked fine at first and I wasn't getting this message, no idea why it stopped working). Is there a way to make such video play in iOS app? If yes, how?
P.S.
I don't want to kick the user out of my app and send him to youtube app or safari.
I also want to be able to count how many times did user play the video, but this topic is probably big enough for a separate question.

Try loading video with this:
[_videoWebView loadHTMLString:html baseURL:[NSURL URLWithString:#"http://www.youtube.com/"]];

Related

Play Youtube Url In Webview without userControl in iOS

I want to play youtube url in UIWebview or MPMoviewviewcontroller.but the restriction is user should not control the playing video.could any one help ?
If you want finer control over youtube videos, theres a library (not written by me) called XCDYoutubeKit. Search for that and look at incorporating it into your app - theres a class in there that is based on MPMoviePlayerController, that allows the playing of youtube videos from their youtube id (I use it, its good). This also means you get a normal player, so you can pause, scrub through, etc.

Cannot replay YouTube video on mobile twice when rel=0

The rel parameter in YouTube API dictates whether or not related videos are shown at the end. When rel=0 the video reverts back to the thumbnail with a play button.
However on mobile (tested on iPhone / iPad / Fire Tablet) when the video goes back to the thumbnail it cannot be played a second time. It just does nothing.
I reported the issue to Google but nothing yet after a few days.
I had to resort to destroying the video and recreating it but this makes for a kind of nasty flickering.
My experience with YouTube issues is they never seem to end up fixing anything related to iOS - so I was wondering if there was any other kind of trick to prevent this.
Test page
The trouble with refreshing a webpage at a specific interval is that you dont know exactly when the video ends so you need to develop a method which the video player sends a signal when the video ends, which would then start the script to refresh the page. Otherwise you end up restarting it in the middle of the video. so personally, I would not even mess with refreshing the page. For Audio players it works ok because audio is smaller and streams more quicker. Video dont.... they always stop to buffer.
So YouTube API uses "Events" and "Listeners", so in particular, you need to design around the Event: "onStateChange".
When onStateChange = "ended" (zero) the video has ended, so then you reload the video player with the same video and set it to its Ready State again.
In theory its very easy you basically need to setup and control the entire video player through javascript. And the API gives examples on that.
http://code.google.com/apis/youtube/js_api_reference.html
http://grizzlyweb.com/webmaster/javascripts/refresh.asp
http://code.google.com/apis/youtube/forum/
Have a look at loop and playlist parameters as well. You can set playlist parameter to video ID and same video can be replayed using this.
So, it will be something like:
http://www.youtube.com/embed/{VIDEO_ID}?wmode=opaque&loop=1&version=3&playlist={VIDEO_ID}
Hope this helps!
Appears to have been fixed by YouTube.
I can now play the video multiple times (on multiple devices) without it getting stuck. Was too busy wondering why my question was getting so little attention that I forgot to check again to see if it was fixed ;-)

Record video inside of iOS app, immediately play and loop

I'm looking for a way for my users to take a video (defaulting to front facing camera, but with the ability to switch) lasting 2 seconds, display that video immediately and have it loop indefinitely (no controls displayed). Essentially mimicking a 2 second gif. I would like to do this in app so they can see the video before posting, and potentially retake. Any ideas? I've found some functionality here: https://developer.apple.com/library/ios/documentation/MediaPlayer/Reference/MPMoviePlayerController_Class/index.html#//apple_ref/c/tdef/MPMovieControlStyle but it doesn't seem to address the entire problem set.
Checkout this guide from Apple:
Using Video

How to play videos in uiwebview ios?

I'm building an article reading app for iphone.I'm parsing JSON content of article in uiwebview.
Some of the articles contains videos,But it does not display in the uiwebview.
JSON format for video is
<iframe src=\"\/\/www.youtube.com\/embed\/hdstrm\" height=\"360\" width=\"640\" allowfullscreen=\"\" frameborder=\"0\">
The uiwebview display empty space at the place of video frame
here is screen shot of uiwebview:
Displaying YouTube videos on iOS requires special treatment and is much less straight forward than you would expect (or hope). You can either display the entire YouTube page and let the user take it from there (or try to programmatically simulate a press on the play button), or you can "steal" the MP4 and play it using the media player.
The second option is better because it allows you to control the UI around the video and doesn't force you to display the entire YouTube page. However, it's important to stress that it requires quite a bit of work and is frowned upon by YouTube. In fact, they change the HTML structure of their pages every 2-3 months so that these mechanisms will break, and you won't be able to access the MP4 file directly without changing your code.
For more information on how to access the media file directly and play it, check out https://github.com/larcus94/LBYouTubeView

Need youtube audio to continue to play when iOS app enters background

My app has a UIWebView that plays specific youtube content within the app. Some of these videos can be lengthy and are more audio centric (e.g. lectures and/or music). I'd like users of the app to be able to leave the app but have the audio of the youtube video continue to play, without the need for hitting a resume or play button. How can this be done? I'm willing to abandon the UIWebView if there is a better alternative.
Thank You.
I work on the same troube. The problem come from the mpmovieplayer which play the movie in ios.
An article of Matt Gallagher said:
"This pause is sent from the CALayer displaying the video frames. This is a private class for an MPMoviePlayerController and is your own AVPlayerLayer for an AVPlayer."
source - http://www.cocoawithlove.com/2011/04/background-audio-through-ios-movie.html
This article is very old (2011), but maybe the problem is similar.
Good luck

Resources