Using Google's youtube API is there a way to determine if a video has been removed or no longer available? - youtube

I have been using the Google data API to search video from Youtube and play it back in a chromeless player as part of a Flash (AS2) swf I have developed. here's my workflow -
Search Youtube with PHP page that includes Zend_Gdata_YouTube class
Retrieve and display videos in a Flash swf which play if user clicks.
Store video ids in database for playback later - like a playlist
Then when the playlist is played (in another swf) the database is read to get the video ids to play and Flash loads the videos as needed.
Here's the problem. While the search works fine and returns thumbnail images of all the videos some of them do not play on click. Using Firebug in firefox I see that the attempted load of the video returns a 204 No content, but there is no info in the response tab. SO ...
a) how would I catch these videos so they dont get returned in the search results?
b) What would happen if a video that did play ok initially later got removed from Youtube, how could I catch this (preferably with flash) and remove it from the playlist (database).
any thoughts?
cheers

Related

Youtube Embedded Player: Prevent video from appearing in User's Watch History

I am writing a webapp that integrates with Youtube and plays Videos using the Youtube Embedded Player.
One feature I'm trying to implement involves preventing a Video that is being watched from being added to the User's Watch History. That way they can watch songs related to movies/tv shows/video games without getting assaulted with potentially spoiler containing videos the next time they log into Youtube.
I have been unable to prevent it by sandboxing the iframe the player is in.
It also looks like removing entries from the Watch History has been deprecated as of August 2016 with the Data API.
Is there any way to prevent Youtube from tracking the video being watched?
Thanks!

Get list of videos uploaded before and after certain video

Youtube use to have a feature where you could click a more videos button while watching any video, and see a snapshot of the uploads playlist with videos uploaded before and after the one you are currently watching.
I am trying to get a list like that with the v3 data API and it seems there is no way. There use to be a way to dictate an index when using the playlistItems call, but now there isn't.
If you go to a channels upload playlist and click play all, you can see a list of videos surrounding the one you are watching, so it seems this functionality is possible, but I don't know how they are doing it.
Any ideas?

How can I link my private videos on YouTube to be played on my website?

How can I link my private videos on YouTube to be played on my website. The point is to bring more viewers to my site by making videos available on my site, yet private on YouTube.
You should set your videos to "unlisted" instead of "private". That
way the video does not show up on your channel or on any search
results but anyone with a link to the video can see it and you can
embed the video on any site.
I didn't try this workaround yet but theoretically it should work, you need to use YouTube API V 3 and follow the below steps:
Set the video's privacy status to unlisted through API.
Embed the video via API in a hidden div.
Use onPlayerStateChange event to check if the video player is currently playing the video, use the API to pause the video at the first second.
If the state changed to "playing" then send an AJAX request to a server side script to revert the the video's privacy status to be private, once you get a confirmation message display the video and use the API to play it.
This should keep the video private even if the user copy & paste the URL in another tab, s/he should get a message that the video is private.
References:
https://developers.google.com/youtube/iframe_api_reference?hl=en
PHP - How to change privacy status of a youtube video through Youtube API v3?

JavaFX project play youtube videos

I work on an automatically music player. To be short, i use the Last.fm api to get a lot of tracks names and tags. Using these tags and some intelligence computing algorithms, once you play a track, the player sets another track (with tags very appropriate to the tags of the track listened before).
I used the youtube API to search for the URL's of the movies, and I managed to make it work. Now I want to make the videos play on my music player. I have tried to place the youtube player on WebView. It works, but not as intended. I want to control that player. I want it to start playing automatically, and I want to get noticed when the video ended so I can start the next one.
Any clues of what should I do to play the videos from youtube based on the search that uses the Youtube API, and to have control over the youtube player that I place on my GUI(make it play and stop from command line)? Or is there any possible way do download the youtube movie and play it using the JavaFX API? I searched google and noticed I cannot download youtube movie into a format that can be played by JavaFX api.
Update Dec 4th, 2015
Some versions of JavaFX 8 are unable to play back youtube video content. Currently, for instance, Java 8u66 cannot playback youtube video content, but Java 8u72 early access release can.
Also note some of the videos referenced in the sample solution are no longer available or are protected from play in embedded video players. So ensure that you perform any tests using available and videos that have not been distribution restricted. Refer to the youtube documentation for information on distribution restriction if need be.
Any clues of what should I do to play the videos from youtube
As a hints to get you started, see code playing YouTube videos in JavaFX and the YouTube HTML5 api.
Here is the sample code I linked running and playing YouTube videos back within a JavaFX WebView with some (very minimal) control over the video playback via interaction with a JavaFX "New Song" button.
Or is there any possible way do download the youtube movie and play it using the JavaFX API? I searched google and noticed I cannot download youtube movie into a format that can be played by JavaFX api.
I think such a usage would violate YouTube's terms of service. I believe YouTube requires you to play the video back using the YouTube video player (let's them insert ads in the video player etc).
5.1 A
you agree not to distribute any part of or parts of the Website or the
Service, including but not limited to any Content, in any medium
without YouTube's prior written authorisation, unless YouTube makes
available the means for such distribution through functionality
offered by the Service (such as the YouTube Player);
5.1 C
you agree not to access Content through any technology
or means other than the video playback pages of the Website itself,
the YouTube Player, or such other means as YouTube may explicitly
designate for this purpose;
I advanced little, but I got stuck to other problems.
First of all, the code from jewelsea was great. Now I could embed the player into a secondary window of my player and it shows the movie based on the URL that i got using the youtube api. But it looks like JavaFX cannot show most of the movies. It shows me the youtube player and an error message saying that I need to install latest version of Adobe Flashplayer. From my research, I noticed that the webView can only show movies with quality set at 240p, not higher.
I have searched a lot on Google how to make my webView to play the 240p quality video. First of all, i tried to set the youtube query parameters (https://developers.google.com/youtube/2.0/developers_guide_protocol_api_query_parameters#formatsp). I tried all the parameters from there: 1,5 and 6. But yet, I did not get the URL of movie with format that can be viewed on the webView of the JavaFX.
I also tried to embed the video quality in the URL of the movie like this:
http:/www.youtube.com/watch?v=og2YZlLhjKs&vq=small:240p ; but it does not work at all. I also wrote that URL in the browser and it looks like the youtube automatically sets the video to the highest quality, no matter what parameter I write in the URL.
The youtube api code that I used is the same like in this webpage: http://www.javacodegeeks.com/2010/05/getting-started-with-youtube-java-api.html
I just moved the main class code to a method that returns the URL of the first video that is in the list, and I changed the " query.setOrderBy(YouTubeQuery.OrderBy.VIEW_COUNT); "
to " query.setOrderBy(YouTubeQuery.OrderBy.RELEVANCE);". And this works fine, it shows the url to proper music videos that I search.
I am sorry for not showing the code of my project but it is big and it contains 2-3 api keys, and if you tell me how to change the video URL http:/www.youtube.com/watch?v=og2YZlLhjKs to work on the code from this website: https:/gist.github.com/jewelsea/1437374 , then I will know that to do to make it work on my project as well;
And the thing about YouTube playback API also enlightened me. I see that API has a lot of functions that could help me to play a lot easier with the video content (make it play, make it stop) but the problem is that I do not have knowledge about javascript programming and it is very sad that I do not have those methods in Java API as well. Maybe I will give it a try and insert javascript code into my webview. But, if I edit the webview using javascript... Is it going to play higher quality movies on the JavaFX webView?

Youtube integration in iOS SDK

How I can integrate Youtube with iOS? Mainly I want to play private videos without asking for login. Login should be hard coded in the app and will not ask user before playing the private video.
Some YouTube videos can be played back in a MPMoviePlayerController - some cannot. When you query a video through the YouTube Data API https://developers.google.com/youtube/2.0/reference#Videos_feed
you'll get back all the content types available for a particular videos, including the Flash player, 3GPP, MP4 (if available), etc. You can use these URLs to load up a MPMoviePlayerController.
This is perfectly fine, but as I've said - not all videos are available to embed this way. Some videos (mainly ones that require adverts to be displayed) can't be put into native controllers.

Resources