Mother’s Finger Cookie
by Thai on June 26, 2010
My wife pointed this out at Zion’s market and I thought that it might be…tasty.
JW HTML5 Player Plugin for WordPress
by Thai on June 13, 2010
This is a plugin for WordPress and it will allow you to post your video with JW’s HTML5 player. It’s just an early release to utilize HTML5′s video capability. The script has been tested with Firefox 3.6.3, Safari 5, and Chrome 5.03. I also tested the plugin under WordPress 3.0 RC3 so it’s ready for the next version. Browsers that don’t support HTML5 video’s tag will fallback to the Flash player.
08-23-10
If you have the jQuery lightbox plugin, this plugin will have issues with it because the lightbox script conflicts with JW’s player. Due to the nature of lightbox, it’s loaded with all of WP’s pages. I will look into this and work around it.
08-16-10
Re-wrote the way the player’s code is initialized. It will auto detect the plugin’s directory for the skin and swf file.
08-08-10
I re-wrote the plugin so that it’s cleaner and meaner. Namepace collision shouldn’t be an issue since I used prefixes for the functions and it’s wrapped in a class wrapper. I didn’t know loading JS files was going to be a huge hurdle with WP. There was barely any resources online and it seems like most devs had the same issue. Now I’m a little wiser about the process, I think I’m going to help out others on Stackoverflow. Please be warned that this is an early build so let me know of any bugs. The plugin is now 0.0.4!
08-02-10
Fixed so that it shouldn’t load actions in the Admin area and jQuery’s library is loaded directly from WordPress’s directory. It’s not a major update but a little something something.
08-01-10
Reverted the skin’s xml to the original file because the minify one was causing issues with IE. One feature that I like about the player is displaying a playlist and I’m thinking about ways to get it going. I’m going to play around with the possibility of an admin panel.
07-27-10
Fixed an issue with how it was loading the skin. PHP generates a JavaScript file and detects the path to the xml skin and swf files under the plugin’s folder. It sorta auto detects your WP installation directories. The script assumes that the “wp-content” folder lives under the root of the domain. I’ll figure out a better way to detect it but for now it’s a fix.
07-25-10
I had to rework the loading of jQuery to accommodate WP’s final launch. I must admit that it’s getting sweeter. I fixed the loading issues which Marc pointed out and it’ll load jQuery before the other dependent files. This plugin is just to demonstrate Longtail’s new player and the neat things you can do with HTML5. I’m excited by all the things that people are doing with it so being able to get positive feedback is one reason why the web community is an outstanding group of people.
Updates
NEW Bug Fix for WP: Only loads with shortcode
NEW Bug Fix for WP: Shouldn’t load in Admin
NEW Bug Fix for IE: Works in IE again
NEW Bug Fix for WP 3: jQuery library loads from WP directory
NEW Bug Fix: Fixed issue when loading the player’s skin
Working On
-Autoplay
-Volume control on autoplay
-Wordpress backwards compatibility
-Update automatically via WordPress’s SVN
-Display poster
-Display playlist for videos
Plugin Features
-Only load dependencies when used by shortcode
-WordPress backwards compatible(compatible with 3.0)
-IE Friendly
Installation
1. Unzip the goodies and upload the folder to your ‘plugins’ folder under the ‘wp-content’ directory.
2. Activate it via the Plugin Admin’s area or upload directly within WP’s admin’s CP.
3. Use the shortcode in your entry to post the video.
Source File
To insert your video in the post just have to upload a video with the Media Manager and copy the source from the Link URL field. If you can’t increase the upload size for WP, then upload your video with an FTP program and link it that way. The next version will support other formats but for now you can upload MP4.
The Shortcode
To embed the player, add this with your desired dimension in your post. By default the plugin will set it to 480 x 320.
-
[jw_html5 src="url/to/your/video.mp4" width="720" height="480"]
It’s as simple as adding the video URL to the shortcode and setting the dimensions. If you have any issues with the plugin please email me or comment your issue and I will walk you through it. Check back for more updates!
Google vs Apple vs Adobe
by Thai on May 20, 2010
One of the many reasons why technology doesn’t get to where it should be is because of lawsuits. Nobody really benefits from it. I don’t think they really know why they’re against each other at this point. One key aspect of any smart business is relationships with other businesses. It is the bridge that will allow you to expand your product effectively through portals you never thought possible. Pretty much like the buddy who comes by to help you move for a case of beer. He does it for the beer and he knows it’ll make you happy. I live in a fantasy world but I’m allowed to dream.
Teddy’s Daily Ritual in a Pie Chart
by Thai on May 12, 2010
I don’t have to wonder what my dog does all day because he leaves a trail everywhere he goes. Sort of like footprint impressions on sand. He’s quite an artist and he seems to always come up with something breathtaking.
Digital Painting of Calla Lillies
by Thai on May 9, 2010

Made this for my wife because she’s the best doggie mommy ever.
Generate a Playlist for HTML5 Video
by Thai on May 4, 2010
I wanted to script a playlist generator for HTML5 without using jQuery and this is what I came up with. What it does is read files from a directory and outputs it in JSON array. It’ll pass the values to JavaScript and with a bit of DOM magic, set the MP4′s path to HTML5′s player. I could’ve easily built the front end with jQuery but I wanted to see the gears of HTML5. If you don’t care about performance then use PHP’s glob() method to find files in a directory. I also added two JS functions from Apple’s dev manual. Sometimes you don’t have to reinvent the wheel.
-
<?php
-
//Grab the files from a directory
-
$dir = "vids";
-
if($f != "." && $f != ".."){
-
$files[] = $f;
-
}
-
}
-
}
-
//Create JS’s header
-
-
foreach($files as $key => $val){
-
-
//inserts the val into the array
-
$file[$key] = $val;
-
-
}
-
-
-
//creates json obj with the array
-
?>
-
-
function playThis(e){
-
-
//prevent the default from happening
-
e.preventDefault();
-
var myVideo = document.getElementsByTagName(‘video’)[0];
-
//grabs the path to the video
-
var newSource = this.getAttribute(‘href’);
-
-
//set it to video src
-
myVideo.src = newSource;
-
myVideo.load();
-
myVideo.play();
-
-
}
-
-
for(i in obj){
-
//create and pull all the elements to manipulate
-
var text = document.createTextNode(obj[i]);
-
var list = document.createElement(‘list’);
-
var href = document.createElement(‘a’);
-
var bullet = document.createElement(‘li’);
-
var output = document.getElementById(‘output’);
-
var all_links = output.getElementsByTagName(‘a’);
-
-
//add the link and set the path href’s attribute
-
href.innerHTML= "<a>" + text.nodeValue + "</a>";
-
href.setAttribute(‘href’, "vids/" + text.nodeValue);
-
//append everything together
-
bullet.appendChild(href);
-
list.appendChild(bullet);
-
output.appendChild(list);
-
//add playThis function to each link
-
all_links[i].addEventListener(‘click’, playThis, false);
-
-
}
-
-
-
// listener function changes src
-
function myNewSrc() {
-
-
var myVideo = document.getElementsByTagName(‘video’)[0];
-
myVideo.src="link/to/your/video.mp4";
-
-
myVideo.load();
-
myVideo.play();
-
-
}
-
-
// function adds listener function to ended event
-
-
function myAddListener(){
-
-
var myVideo = document.getElementsByTagName(‘video’)[0];
-
myVideo.addEventListener(‘ended’,myNewSrc,false);
-
-
}
You have to place the JS source tag at the bottom of the markup otherwise it won’t parse properly. It’s just good practice to load your scripts at the bottom of the document. You can also load it by creating an init() method if you want to be really nasty. I’ve set this page up so that it fits snug with the iPad’s screen width. There are ways to have fallbacks so that it degrades to Flash but that’s outside the scope of this write up. NETTUTS goes over it a bit.
-
<!DOCTYPE html>
-
<html lang="en">
-
<head>
-
<meta charset="utf-8" />
-
<meta name="viewport" content="width=device-width" />
-
<style type="text/css">
-
#player {
-
padding-top: 6px;
-
}
-
#output{
-
display:block;
-
width:480px;
-
height:220px;
-
background-color:#CCC;
-
color:#000;
-
padding:6px;
-
}
-
-
#output {width:350px; height:200px; background-color:#CCC;}
-
#output ul, li{list-style:none;}
-
hgroup{list-style:none;}
-
-
</style>
-
</head>
-
-
<body id="index" class="home" onLoad="myAddListener()">
-
<header id="header" class="vid">
-
</header><!– /#header –>
-
-
<aside id="featured" class="body">
-
<article>
-
<figure>
-
<video src="vids/video.mp4"
-
controls="controls"
-
id="player"
-
poster="your_logo.jpg"
-
height="480" width="720"></video>
-
</figure>
-
<hgroup>
-
</hgroup>
-
</article>
-
</aside><!– /#featured –>
-
</body>
-
</html>
Check out the working sample to see how it’s set up. You can only view this in Safari and Chrome but maybe by 2049 HTML5 will be fully implemented. I don’t think HTML5′s video will mature anytime soon, but it doesn’t hurt to see what the future holds. It has a lot of catching up to do if it wants to out do Flash.
Flash Video on Mobile Devices Thanks to Skyfire
by Thai on April 29, 2010
I guess Flash made it to the Andriod and it’s in the beta state. A huge chunk of the web experience is now possible. It’s not perfect but it’s a great start. The best part is when Skyfire detects a viewable Flash video, it’ll notify you or you can click on menu to see if it’ll play. What I notice is that it’ll pull the video if your video’s source is rendered in the html. Small step for Android, giant leap for Flash.
Hot Sex Now Card
by Thai on April 7, 2010
I saw this card and thought it was a little too straight forward ,but the inside gave it a twist.
Detect iPad’s Safari Browser and Redirect to HTML5 Page
by Thai on April 4, 2010
I’m upset that Apple decided not to support Flash for the iPad and instead embraced html5 as their weapon of choice to implement video content. I wasn’t impressed with html5 until I saw the guys at Google ported Quake 2 over from Java. The potential dawned on me. I guess using the native language to handle the DOM isn’t so bad. You just have to roll up your sleave and tango JS into some bedroom boom boom. After all, parsing the native language is faster.
The server side script has to detect the user agent sent by the browser and this is what it’ll send in the http request.
-
Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10
A simple redirect with php’s header() method will send the client to the page according to the device’s browser or OS. I recommend that the script should look for stuff where it’s specific to the device. You don’t want to serve them your iPhone site if you’re checking for “mobile” in the request.
-
<?php
-
-
$device = $browser[0];
-
-
function get_agent($string){
-
if($string == ‘ipad’){
-
//redirect browser to the html5 page
-
} else {
-
$foo = ‘Unidentified device’;
-
}
-
return $foo;
-
}
-
-
get_agent($device);
-
-
?>
This skeleton of html5 markup has the device’s viewport value set to a constant so that it fits the viewport of the current device such as the iPad. The controls can be skinned with Javascript and CSS to give it some DOM visual effects.
-
<!DOCTYPE html>
-
<html lang="en">
-
<head>
-
<meta charset="utf-8" />
-
<meta name="viewport" content="width=device-width" />
-
<style type="text/css">
-
-
#player {
-
padding-top: 6px;
-
}
-
-
aside, header, footer, body{display: block;}
-
-
</style>
-
</head>
-
-
<body id="index" class="home">
-
<header id="header" class="vid">
-
</header><!– #header –>
-
-
<aside id="featured" class="body">
-
<article>
-
<figure>
-
<video src="http://www.site.com/your/video.mp4" controls="controls" id="player"></video>
-
</figure>
-
<hgroup>
-
</hgroup>
-
</article>
-
</aside><!– #featured –>
-
<footer></footer><!– #footer–>
-
</body>
-
</html>
So that’s the basics on how to get your site to figure out the user agent and then take them to a page that’s html5 formatted. You can view the source on the working sample in Safari or Chrome to see the structure. It’s missing other elements but the W3C Editor’s Draft outlines all the new tags. Some of the features I look forward seeing developers take advantage of will certainly give Flash reasons to fine tune their song and dance.
Rotate Header Based on Time of Day
by Thai on March 16, 2010
I made this because I’ve seen a php tutorial on NETTUTS that’s pretty cool and thought of a client side version just for the hell of it. It basically changes the header based on the time of day it is. You can use it to change your site’s logo too. The script is insanely simple and didn’t really need commenting. There’s a default class so that if the user decides to turn off Javascript, it’ll fall back to your default image.
-
$(document).ready(function(){
-
//create date object and get the time
-
var date = new Date();
-
var time = date.getHours();
-
-
var noon = 12;
-
var midnight = 24;
-
var dinner = 18;
-
-
//cache the header div
-
var header = $("#header");
-
-
if(time < noon ){
-
header.removeClass("default").addClass("morning");
-
}else if(time <= midnight && time >= dinner){
-
header.removeClass("default").addClass("night");
-
}else{
-
header.removeClass("default").addClass("noon");
-
-
}
-
});//closing tag for jQuery contructor




