Learning to Love the API: Video Examples
Thursday, October 7th, 2010
Player API
You can control the playback of a video using the YouTube Player API. Here is an snippet from YouTubeCC.com. The full script is located at: caption-scripts.js
var ytplayer = null;
function onYouTubePlayerReady(playerId) {
// set up player
ytplayer = document.getElementById('videoplayer');
ytplayer.addEventListener('onStateChange', 'onytplayerStateChange');
ytplayer.addEventListener('onError', 'onPlayerError');
}
.
.
.
// return focus to video player, seek and play
$("#videoplayer").focus();
ytplayer.seekTo( gotoSec, true);
ytplayer.playVideo();
Data API
The Data API can be used to search, retrieve, edit and even upload videos!
Our particular upload application is written in Coldfusion and tied into a larger system – so, I can’t show you everything. However, I will display one of the more important parts. Here, the program sends the user’s data to YouTube. In response, YouTube will return a Token and Address to where we can point a direct upload form:
Upload Video Meta Data Error
Feel free to contact me if you are writing something similar and would like to see more of the CF code.
gabriel nagmay (dot com) | Archive » Learning to Love the API Says:
[…] Video (YouTube) […]
Juventino Says:
Hello,
sorry for my english…
Please can you send an example of upload a video to youtube???
Thanks in advance.
Juven
nagmay Says:
Juven,
Uploading videos is complicated – mostly because you have to deal with authentication – which is a multi-step process. As stated above, our uploader is tied into a larger authentication system. Sending you all the code wouldn’t do you much good.
I would recommend looking over the documentation: https://developers.google.com/youtube/2.0/developers_guide_protocol#Uploading_Videos
Sorry that I can’t be more helpful.
gabriel nagmay (dot com) | Archive » ALL THE THINGS! Says:
[…] Video upload API (YouTube) […]