<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>360innovate Blog &#187; jquery plugin html html5</title>
	<atom:link href="http://www.360innovate.co.uk/blog/tag/jquery-plugin-html-html5/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.360innovate.co.uk/blog</link>
	<description></description>
	<lastBuildDate>Thu, 09 Feb 2012 16:02:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>jCaps &#8211; easier html5 video captions with jQuery</title>
		<link>http://www.360innovate.co.uk/blog/2010/02/jcaps-making-html5-video-captions-easier-with-jquery-plugin/</link>
		<comments>http://www.360innovate.co.uk/blog/2010/02/jcaps-making-html5-video-captions-easier-with-jquery-plugin/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 16:22:59 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[Web Development Articles]]></category>
		<category><![CDATA[jquery plugin html html5]]></category>

		<guid isPermaLink="false">http://www.360innovate.co.uk/blog/?p=1661</guid>
		<description><![CDATA[It&#8217;s been a good year so far for html5 video. You might have noticed that YouTube and Vimeo have introduced their own player, and with the iPad&#8217;s lack of flash support, we are likely to see the tag used in more and more places, at least as an option alongside Flash. Bruce Lawson of Opera [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.360innovate.co.uk%2Fblog%2F2010%2F02%2Fjcaps-making-html5-video-captions-easier-with-jquery-plugin%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.360innovate.co.uk%2Fblog%2F2010%2F02%2Fjcaps-making-html5-video-captions-easier-with-jquery-plugin%2F&amp;source=360innovate&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>It&#8217;s been a good year so far for html5 video. You might have noticed that <a href="http://www.youtube.com/html5">YouTube</a> and <a href="http://vimeo.com/blog:268">Vimeo</a> have introduced their own player, and with the iPad&#8217;s lack of flash support, we are likely to see the tag used in more and more places, at least as an option alongside Flash.</p>
<p>Bruce Lawson of Opera recently showed off a proof-of-concept subtitling system for html5 video. It&#8217;s a great concept, and I&#8217;m happy to present the work I&#8217;ve done on the subject, turning it into a jQuery plugin, with a few extra enhacements. I hope that doing this will provide an easy API for front-end-developers.</p>
<p><a href="http://www.360innovate.co.uk/blog/jcaps.html">Check out the demonstration here.</a></p>
<p>The latest version has the following features:</p>
<ul>
<li>Multiple language support</li>
<li>Public methods to show, hide, or toggle captions</li>
<li>Ability to show full transcript in the selected language</li>
</ul>
<h3>The HTML</h3>
<p>Make sure you&#8217;re using the HTML5 Doctype. Link to the stylesheet, jQuery and the plugin as below:<br />
<code><br />
&lt;!DOCTYPE HTML&gt;<br />
<span style="padding-left: 30px;">&lt;html lang="en"&gt;</span><br />
<span style="padding-left: 60px;">&lt;head&gt;</span><br />
<span style="padding-left: 90px;">&lt;link href="jcapstyles.css" rel="stylesheet" /&gt;</span><br />
<span style="padding-left: 90px;">&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.js"&gt;&lt;/script&gt;</span><br />
<span style="padding-left: 90px;">&lt;script src="jquery.jcap.js"&gt;&lt;/script&gt;</span><br />
<span style="padding-left: 60px;">&lt;/head&gt;</span><br />
</code></p>
<p>Next, embed the video in the page, doing something like the following. I&#8217;m using Bruce&#8217;s slightly silly sample video here, since it has a multi-language transcription already!</p>
<p><code><br />
&lt;video id="myVid" width="400" src="http://www.360innovate.co.uk/blog/leverage-a-synergy.ogv" autobuffer controls&gt;<br />
&lt;p&gt;This page is to demonstrate open HTML5 video, so if you're not using a browser that can display the open Ogg Theora codec, there's not much to see. Sorry!&lt;/p&gt;<br />
&lt;/video&gt;<br />
</code></p>
<p>Finally, create the transcript HTML.</p>
<p><code><br />
&lt;div id="transcripts"&gt;<br />
<span style="padding-left: 30px;">&lt;div lang="en"&gt;</span><br />
<span style="padding-left: 60px;">&lt;p&gt;</span><br />
<span style="padding-left: 90px;">&lt;span data-begin=1 data-end=6&gt;Hi, my name's Dr Archimedes Einstein and I'm a Doctor of Science at the University of Science&lt;/span&gt;</span><br />
<span style="padding-left: 60px;">&lt;/p&gt;</span><br />
<span style="padding-left: 30px;">&lt;div/&gt;</span><br />
&lt;div/&gt;<br />
</code></p>
<p>Note that you must give the child div a &#8216;lang&#8217; attribute.</p>
<h3>The JavaScript</h3>
<p>This is where the action happens. First, pass an anonymous function to jQuery to execute as a callback for when the document is ready. Then, call the jCaps plugin, with an object literal as a parameter. You should pass the following as a bare minimum, but there are other options that can be passed &#8211; see the code file for details.</p>
<p><code><br />
$(function(){<br />
<span style="padding-left: 30px;">$("#myVid").jCaps({</span><br />
<span style="padding-left: 60px;">transcriptsDiv: $('#transcripts'),</span><br />
<span style="padding-left: 60px;">language: $('select[name="changeLang"]').val()</span><br />
<span style="padding-left: 30px;">});</span><br />
})<br />
</code></p>
<p>Note that you must pass a transcripts div as a bare minimum. This will hide the transcripts div from view. By default, captions are not shown. You can switch it on by attaching the following methods to a click event on a button, or link for example:</p>
<p><code><br />
$('#toggleCaptions').click(function(){<br />
<span style="padding-left: 30px;">$('#myVid').jCaps.toggle();</span><br />
});<br />
</code><br />
<code><br />
$('#switchOn').click(function(){<br />
<span style="padding-left: 30px;">$('#myVid').jCaps.switchOn();</span><br />
});<br />
</code><br />
<code><br />
$('#switchOff').click(function(){<br />
<span style="padding-left: 30px;">$('#myVid').jCaps.switchOff();</span><br />
});<br />
</code><br />
switchOff() and switchOn() should be self-explanatory; toggle() will show the captions if they are hidden, and vice-versa.</p>
<p>You can change the language of the captions by calling the switchLanguage method:<br />
<code><br />
$('select[name="changeLang"]').change(function(){<br />
<span style="padding-left: 30px;">$('#myVid').jCaps.switchLanguage('ja');</span><br />
});<br />
</code><br />
There is one final public method at present: swapOut(). This shows the full transcript in the selected language when activated.</p>
<p><code><br />
$('#transcript').click(function(){<br />
<span style="padding-left: 30px;">$('#myVid').jCaps.swapOut();</span><br />
});<br />
</code></p>
<p>That&#8217;s it! You can <a href="http://www.360innovate.co.uk/blog/jcaps.html">view the demonstration here</a>.</p>
<p>Please note that this is very experimental, and might change or break at any time. You can <a href="http://github.com/johnmcc/jCaps">download the source at github</a>, and of course I would welcome any feedback or pull requests. Credit for the original script goes to Bruce Lawson, Philip Jägenstedt, and Daniel Davis.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.360innovate.co.uk/blog/2010/02/jcaps-making-html5-video-captions-easier-with-jquery-plugin/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
<enclosure url="http://www.360innovate.co.uk/blog/leverage-a-synergy.ogv" length="4533339" type="video/ogg" />
		</item>
	</channel>
</rss>

