Tomomi Imura

Tomomi Imura

An Open Web advocate and front-end engineer, who loves everything mobile, and writes about HTML5, CSS, JS, UX, tech events, gadgets, etc. She unintentionally got 15min of fame by creating The HTTP Status Cats. Also, the opinions expressed here are solely her own and do not express the views or opinions of my employer.

Twitter LinkedIn Instagram Github Flickr

Creative Commons License
My articles are licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

iCuteOverload Update – Launch YouTube app

OK, iCuteOverload beta (preview at: on iPhone!) is almost official.

Before handing to Megan, I made another change – converting YouTube Flash embed (that is not supported by iPhone) to YouTube video link to open in iPhone’s YouTube app. Thanks to Isao Yagi, who gave me tips to my regex question on php-user list, I could make this work.

Here’s how the regex code in php looks.

pattern to look for:

$p = ' /<object[\S\s]+?http:\/\/www\.youtube\.com\/v\/([\w\-]+)"[\S\s]+? <\/object>/i ';.<br />

This look for a html object tag that includes YouTube link, and capture the video ID to re-create a new link.
As long as I found, the video ID can contain any alpha-numeric char (\w) and hyphen (-).
Use /i to make it case-insensitive just in case.

replace string:

$r = ' <a href="\1"><img src="images/watch_youtube.png" alt="watch!" width="200" height="56"/></a>';<br />

then use preg_replace function to replace the string:

$content = preg_replace($p, $r, $content);

I use an image button link to launch YouTube app.
The captured video ID for Flash is now taken as a query string. This should work fine!

However!!! I just found that NOT all YouTube videos are available for iPhone yet…
So when I try the latest CuteOverload entry, I got this sad message, “Could not load movie”.

According to Apple Support, they will apparently be in sync by the end of the summer.

comments powered by