Sunday, March 11, 2007


Flash Player for Youtube : I have wrote a simple application that can see video contents of Youtube only by remote control such as Rimo. I would like to optimize the application for Wii, but I don't buy Wii in my home yet X-<

I wrote the client only using Flash 8, and the main source code of ActionScript is the following. You can get the all source codes that includes the flash file and the server side file from the link.
var rssXML = new XML();
rssXML.ignoreWhite = true;

var rssItemNum = 0;
var rssItemTitle = new Array();
var rssItemURL = new Array();
var currtemNum = 0;

function updateItem(xml) {
var channelNode = xml.firstChild.firstChild;
var channelNodesNum = channelNode.childNodes.length;
if (channelNodesNum <= 0)
return;
rssItemNum = 0;
rssItemTitle = new Array();
rssItemURL = new Array();
for(var i = 0; i < channelNodesNum; i ++) {
if(channelNode.childNodes[i].nodeName.toLowerCase() == "item") {
var itemNodesNum = channelNode.childNodes[i].childNodes.length;
var itemName = "";
var itemUrl = "";
for(var j = 0; j < itemNodesNum; j ++) {
if(channelNode.childNodes[i].childNodes[j].nodeName.toLowerCase() == "title") {
itemName = schannelNode.childNodes[i].childNodes[j].firstChild.nodeValue;
}
if(channelNode.childNodes[i].childNodes[j].nodeName.toLowerCase() == "link") {
itemUrl = channelNode.childNodes[i].childNodes[j].firstChild.nodeValue;
}
}
rssItemNum++;
rssItemTitle.push(itemName);
rssItemURL.push(itemUrl);
}
}
}
rssXML.onLoad = function(result) {
if (!result)
return;
updateItem(this);
if (0 < rssItemNum) {
flvMedia.stop();
flvMedia.contentPath = rssItemURL[0];
flvMedia.play(0);
}
}
rssXML.load("http://www.cybergarage.org/flash/youtube.xml");

function updataContentIndex(offset)
{
currtemNum += offset;
if (currtemNum < 0)
currtemNum = rssItemNum-1;
if ((rssItemNum-1) < currtemNum)
currtemNum = 0;
}

var flvPlayListener:Object = new Object();
flvPlayListener.complete = function(){
updataContentIndex(1);
flvMedia.stop();
flvMedia.contentPath = rssItemURL[currtemNum];
flvMedia.play(0);
}
flvMedia.addEventListener("complete",flvPlayListener);

var keyListener = new Object();
keyListener.onKeyDown = function() {
if (Key.getCode() == Key.RIGHT) {
updataContentIndex(1);
flvMedia.stop();
flvMedia.contentPath = rssItemURL[currtemNum];
flvMedia.play(0);
}
if (Key.getCode() == Key.LEFT) {
updataContentIndex(-1);
flvMedia.stop();
flvMedia.contentPath = rssItemURL[currtemNum];
flvMedia.play(0);
}
}

Key.addListener(keyListener);
I wrote a php file for the client to output a RSS format of YouTube :: Recently Featured that includes URLs of the FLV files directly. To run this sample of PHP, you might have to add the following patch into HTTP.php because the head function might ignore query strings of the specified URL.
# diff HTTP.120.php HTTP.php
153a154,155
> if (0 < @strlen($purl['query']))
> $path = $purl['path'] . "?" . $purl['query'];
Please check it :-)

Comments:
Hi, Satoshi!

Please excuse if my question is not related with the "Flash Player for YouTube" subject. I just want to make sure you can read my post. ;)

First of all I want to congratulate you for the excellent work you have done on CyberLink for Java.

I am studying a Master Degree in Mexico and my final work is about UPnP and "spontaneous networks".

I want to point your attention to what is stated on slide number 30 of the following ppt from a colleague in Finland:

http://www.tml.tkk.fi/Opinnot/T-111.5350/2006/Home_AV_Networks.pdf

Is that correct, that CyberLink manages AutoIP automatically if not DHCP server is available? I have read in older posts from you that it doesn't.

I appreciate your help on this question.

Luis
Cuernavaca, Mexico
 
Hi Luis,

The CyberLink doesn't support to maneage AutoIP and DHCP directlly, because the functions are supported on the operating systems.

Satoshi Konno
 
Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?