Flash Player for Youtube

I have wrote a simple application that can see video contents of Youtube only by remote control. I would like to optimize the application for Wii, but the project is stalled :-<

wii-youtube-01.jpg

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 if you want.


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);
Topic attachments
I Attachment Action Size Date Who Comment
JPEGjpg wii-youtube-01.jpg manage 89.1 K 2010-02-02 - 21:56 SatoshiKonno  
Topic revision: r1 - 2010-02-02 - 22:01:14 - SatoshiKonno
 

Copyright © 2012 by Satoshi Konno Powerd by TWiki logoTWiki.