スキップしてメイン コンテンツに移動

投稿

ラベル(youtube)が付いた投稿を表示しています

JSONP + Push State: Youtube Application Example

Improve Performance for MySQL CALC_FOUND_ROWS with LIMIT OFFSET Push State Push state is html5 technology that records browsing history in javascript without actual page refresh. Push state is useful for recording Ajax request, which cannot record the browsing history normally, and telling the corresponding url for the Ajax request to browser. The minimum push state code is below: // push the browser state if (typeof(history.replaceState) !== "undefined") { history.pushState({prop1: "a", prop2:"b"}, null, "/url/?param1=param"); } // when browser back button is pressed, pop state event is fired // pop state handler is registered in the folloing code window.onpopstate = function (event) { if (event.state == null) { return; } // do something nice ;) // using "event.state.prop1" for example }; The usage of push state is quite simple. One thing you should remember is that when pop state event is fired, the browse

Check Youtube Video Existance by ID

I have managed a lot of youtube videos (not owned by me) by youtube video ID to show them on my web page. But sometimes videos were unavailable suddenly (because of copyright issues or simply deleted etc.) So I have created tiny program for check availablitiy of youtube videos by youtube video ID. Here is the code. // print out unavailable videos String[] ids = new String[]{"id1", "id2"}; for(String id : ids) { Thread.sleep(1000); if(!checkExistance(id)) { System.out.println(id); } } public static String checkExistance(String id) { try{ // any method is fine as long as you can get contents from url getStringContentsFromURL("https://gdata.youtube.com/feeds/api/videos/"+id, "utf-8"); } catch(Exception e) { return false; } return true; } Example implementation for getStringContentsFromURL method. Sorry the implementation is a bit circumlocutory because I designed the co

Get Youtube Video Detail Information Only Using Javascript

Demo URL Title Duration (Sec) View Count Source code <table border="1"> <tbody> <tr> <td>URL</td> <td><input type="text" id="youtubeVideo_url" style="width:100%"></td> </tr> <tr> <td>Title</td> <td><div id="youtubeVideo_title"></div></td> </tr> <tr> <td>Duration (Sec)</td> <td><div id="youtubeVideo_duration_seconds"></div></td> </tr> <tr> <td>View Count</td> <td><div id="youtubeVideo_view_count"></div></td> </tr> </tbody> </table> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script type="text/javascript"> $("#youtubeVideo_url").keyup(function(e){ delay(function(){ var url = $('#yout

Get Youtube Information by PHP cURL

I have written small code snippet for getting information from Youtube by PHP with cURL! The code itself is nothing special, really straightforward manner. The following getVideoInfo function takes youtube video id, access to youtube api and return back the detail video information. function getVideoInfo($id) { try { $req = request('http://gdata.youtube.com/feeds/api/videos/' . $id); $xmlStr = $req->getResponseData(); $xml = simplexml_load_string($xmlStr); $xml->registerXPathNamespace('x', 'http://www.w3.org/2005/Atom'); $xml->registerXPathNamespace('media', 'http://search.yahoo.com/mrss/'); $xml->registerXPathNamespace('yt', 'http://gdata.youtube.com/schemas/2007'); $title = $xml->xpath('/x:entry/media:group/media:title'); $duration_seconds = $xml->xpath('/x:entry/media:group/yt:duration/@seconds'); if (empty($title

Youtube API + GAEJ + FreeMarker + Spring

I have developed very very simple youtube sample application on Google App Engine. Internally I have used FreeMarker and Spring. The purpose of this blog entry is just giving hints how to use Spring + FreeMarker on GAEJ with youtube API example. Youtube API Here is the code for extracting video url etc from Youtube API response. I frequently use JDOM for parsing XML. package com.dukesoftware.gaej.youtube; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.util.ArrayList; import java.util.List; import org.jdom.Document; import org.jdom.Element; import org.jdom.JDOMException; import org.jdom.Namespace; import org.jdom.input.SAXBuilder; import org.jdom.xpath.XPath; import com.dukesoftware.utils.io.JDOMUtils; import com.dukesoftware.utils.io.MinimumIOUtils; public class YouTube { private final static XPath XPATH_MEDIA; private final static Namespace NS_MEDIA = Namesp

ActionScript 3.0: Hit Youtube API

I wrote a tiny program for getting Youtube video information by hitting Youtube API in ActionScript 3.0. Some generic classes or methods might be missing but I think you can easily guess what they are doing and can add them easily yourself. Example Usage Ok, starting from the example usage. package utils.video { import flash.display.Sprite; import utils.file.SyncFileSaveDownLoader; import utils.ITaskProgressCounter; import utils.TaskProgressCounter; import utils.video.youtube.YoutubeAPI; import utils.video.YoutubeFLVURLGetEvent; import utils.video.youtube.YoutubeLocalCacheManager; import utils.video.youtube.YoutubeVideoEntryDispatcher; import utils.video.youtube.YoutubeVideoEntryEvent; public class Tester extends Sprite { private var downloader:SyncFileSaveDownLoader = new SyncFileSaveDownLoader(); private var youtubeLocalCacheManager:YoutubeLocalCacheManager = new YoutubeLocalCacheManager("c:\\temp\\youtube&qu