a ver si me podeis ayudar. Os pongo en antecedentes. Tengo una película (.fla) que carga datos de un feed RSS de dailymotion (archivo XML). Necesito que se cargue el último video publicado y la información que le corresponde (título y descripción). He conseguido cargar el titulo la descripción y aislar el identificador del vídeo de su etiqueta (<media:content url="http://www.dailymotion.com/embed/video/xhcqml -----> identificador: xhcqml ).
Para la visualización del vídeo cargo mediante una clase externa el visor de vídeos de DAILYMOTION mediante un código que ellos han creado. Necesito pasar el identificador del vídeo que he aislado en el timeline del flash (xhcqml) al archivo as para q el visor del dailymotion lo reproduzca.
Código de lectura del XML donde saco los datos del titulo la descripción y aislo el identificador del vídeo:
Código ActionScript :
stop();
var XmlExterno:XML;
//Carga el XML
function CargarXML() {
var loader:URLLoader = new URLLoader();
ponerListeners(loader);
var peticion:URLRequest=new URLRequest("dailymotion.xml");
loader.load(peticion);
}
function ponerListeners(dispatcher:IEventDispatcher):void {
dispatcher.addEventListener(Event.COMPLETE, completeHandler);
}
//Funcion que se ejecuta cuando termina la descarga.
function completeHandler(event:Event):void {
var codigo_final:String="";
var cargador:URLLoader=event.target as URLLoader;
XmlExterno=new XML(cargador.data);
var media:String="media:player";
for each (var nodo in XmlExterno.children()) {
for each (var nodo2 in nodo.children()) {
for each (var nodo3 in nodo2.children()) {
if (nodo2.localName()=="item") {
for each (var nodo4 in nodo3.children()) {
if (nodo4.localName()=="content") {
var codigo_URL:String=nodo4.@url;
var barra:int=codigo_URL.lastIndexOf("/");
var codigo:String=codigo_URL.substr(barra+1,codigo_URL.length);
if (codigo_final=="") {
codigo_final=codigo;
}
//trace(codigo);
break;
}
break;
}
}
txt_content.htmlText=nodo.item.title[0];
txt_content_body.htmlText=nodo.item.description[0];
}
}
}
//trace(codigo_final);
var textofinal:String='"'+codigo_final+'"';
//CODIGO FINAL ES EL IDENTIFICADOR DEL VIDEO QUE TIENE Q ESTAR ENTRECOMILLADO
trace(textofinal);
}
//Empezamos
CargarXML();Código del XML donde se encuentra la información:
Código XML :
<?xml version="1.0" encoding="utf-8"?> <rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:media="http://search.yahoo.com/mrss" xmlns:dm="http://www.dailymotion.com/dmrss"> <channel> <title>Zoomin_Espana - V�deos m�s recientes - Dailymotion</title> <link>http://www.dailymotion.com/user/Zoomin_Espana/1</link> <description></description> <itunes:subtitle>Dailymotion - Zoomin_Espana's Videos M�s Recientes</itunes:subtitle> <itunes:summary></itunes:summary> <itunes:owner> <itunes:name>Dailymotion</itunes:name> <itunes:email>[email protected]</itunes:email> </itunes:owner> <itunes:author>Zoomin_Espana</itunes:author> <itunes:image href="http://www.dailymotion.com/images/dailymotion_itunes.jpg"/> <itunes:explicit>no</itunes:explicit> <itunes:category text="TV & Film" /> <language>en-US</language> <lastBuildDate>Thu, 03 Mar 2011 17:38:32 +0100</lastBuildDate> <image> <url>http://www.dailymotion.com/images/dailymotion.jpg</url> <title>Zoomin_Espana - V�deos m�s recientes - Dailymotion</title> <link>http://www.dailymotion.com/user/Zoomin_Espana/1</link> <width>400</width> <height>144</height> </image> <dm:link rel="uql" href="http://www.dailymotion.com/rss/user/Zoomin_Espana/1" type="application/rss+xml"/> <dm:link rel="sort_by_visited-week" title="Los + vistos" href="http://www.dailymotion.com/rss/visited-week/user/Zoomin_Espana/1" type="application/rss+xml"/> <dm:link rel="sort_by_rated-week" title="M�s Valorados" href="http://www.dailymotion.com/rss/rated-week/user/Zoomin_Espana/1" type="application/rss+xml"/> <dm:link rel="next" href="http://www.dailymotion.com/rss/user/Zoomin_Espana/2" type="application/rss+xml"/> <dm:link rel="nextUql" href="http://www.dailymotion.com/rss/user/Zoomin_Espana/2" type="application/rss+xml"/> <item> <title>Resumen de las bolsas de Espa�a, Europa, EEUU y Asia</title> <link>http://www.dailymotion.com/video/xhcqml_resumen-de-las-bolsas-de-espana-europa-eeuu-y-asia_news</link> <description><![CDATA[<a href="http://www.dailymotion.com/video/xhcqml_resumen-de-las-bolsas-de-espana-europa-eeuu-y-asia_news"><img align="right" width="120" height="90" src="http://static2.dmcdn.net/static/video/358/741/29147853:jpeg_preview_medium.jpg?20110303173014" style="border: 2px solid #B9D3FE;"></a><p>Cierre y situaci�n a media jornada en el IBEX y en los mercados europeo, asi�tico y estadounidense.</p><p>Autor: <a href="http://www.dailymotion.com/Zoomin_Espana"><img src="http://static2.dmcdn.net/static/user/373/304/35403373:avatar_medium.jpg?20110214154454" width="80" height="80" alt="avatar"/>Zoomin_Espana</a><br />Etiquetas: <a href="http://www.dailymotion.com/tag/Internacional">Internacional</a> <a href="http://www.dailymotion.com/tag/zoomin">zoomin</a> <br />Enviado: 03 marzo 2011<br />Valoraci�n: 0.0<br />Votos: 0<br /></p>]]></description> <author>[email protected] (Zoomin_Espana)</author> <itunes:author>Zoomin_Espana</itunes:author> <itunes:explicit>no</itunes:explicit> <itunes:summary>Cierre y situaci�n a media jornada en el IBEX y en los mercados europeo, asi�tico y estadounidense.</itunes:summary> <itunes:subtitle>Cierre y situaci�n a media jornada en el IBEX y en los mercados europeo, asi�tico y estadounidense.</itunes:subtitle> <dm:videorating>0.0</dm:videorating> <dm:videovotes>0</dm:videovotes> <dm:link rel="uql" href="http://www.dailymotion.com/rss/video/xhcqml_resumen-de-las-bolsas-de-espana-europa-eeuu-y-asia_news" type="application/rss+xml"/> <dm:link rel="userProfile" href="http://www.dailymotion.com/rss/Zoomin_Espana" type="application/rss+xml"/> <dm:views>5</dm:views> <dm:comments>0</dm:comments> <dm:favorites>0</dm:favorites> <dm:id>xhcqml</dm:id> <dm:author>Zoomin_Espana</dm:author> <dm:loggerURL>http://logger.dailymotion.com/video/access/xhcqml?session_id=&referer=&country=ES&key=cuk0v9ngj90of34djlhhyjc&v=4d6fee18&i=580207e7&h=5e7badb890a065603511fbefb6eacc67</dm:loggerURL> <dm:authorAvatar>http://static2.dmcdn.net/static/user/373/304/35403373:avatar_medium.jpg?20110214154454</dm:authorAvatar> <dm:relativeDate>enviado hace 38 minutos</dm:relativeDate> <dm:channels>news</dm:channels> <pubDate>Thu, 03 Mar 2011 17:00:31 +0100</pubDate> <guid>http://www.dailymotion.com/video/xhcqml_resumen-de-las-bolsas-de-espana-europa-eeuu-y-asia_news</guid> <media:title>Resumen de las bolsas de Espa�a, Europa, EEUU y Asia</media:title> <media:credit>Zoomin_Espana</media:credit> <media:thumbnail url="http://static2.dmcdn.net/static/video/358/741/29147853:jpeg_preview_large.jpg?20110303173014" height="240" width="320" /> <media:player url="http://www.dailymotion.com/video/xhcqml_resumen-de-las-bolsas-de-espana-europa-eeuu-y-asia_news" height="360" width="480"><![CDATA[<iframe frameborder="0" width="480" height="360" src="http://www.dailymotion.com/embed/video/xhcqml"></iframe>]]></media:player> <media:group> <media:content url="http://www.dailymotion.com/embed/video/xhcqml" type="text/html" duration="128" width="480" height="360"/> <media:content url="http://www.dailymotion.com/swf/video/xhcqml" type="application/x-shockwave-flash" duration="128" width="480" height="360"/> </media:group> <itunes:keywords>Internacional, zoomin</itunes:keywords> <media:category label="Internacional">Internacional</media:category> <media:category label="zoomin">zoomin</media:category> </item>
EL CODIGO QUE EXTRAIGO DEL XML EN ESTE CASO ES "xhcqml"
Código del archivo que carga el visor de DAILYMOTION:
Código ActionScript :
package {
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.system.Security;
public class CargarVideo extends MovieClip {
// The player SWF file on www.dailymotion.com needs to communicate with your host
// SWF file. Your code must call Security.allowDomain() to allow this communication.
Security.allowDomain("www.dailymotion.com");
// This will hold the API player instance once it is initialized.
public var player:Object;
public var loader:Loader = new Loader();
public function CargarVideo() {
this.loader.contentLoaderInfo.addEventListener(Event.INIT, this.onLoaderInit);
this.loader.load(new URLRequest("http://www.dailymotion.com/swf?enableApi=1"));
}
public function onLoaderInit(event:Event):void {
addChild(this.loader);
this.loader.content.addEventListener("onReady", this.onPlayerReady);
this.loader.content.addEventListener("onError", this.onPlayerError);
this.loader.content.addEventListener("onStateChange", this.onPlayerStateChange);
}
public function onPlayerReady(event:Event):void {
// Event.data contains the event parameter, which is the Player API ID
trace("player ready:", Object(event).data.playerId);
// Save a reference to this player's instance
this.player=this.loader.content;
// Set appropriate player dimensions for your application
this.player.setSize(990, 570);
// Once this event has been dispatched by the player, we can use
// cueVideoById, loadVideoById, cueVideoByUrl and loadVideoByUrl
// to load a particular YouTube video.
//AQUI ES DONDE TIENE QUE IR FINALMENTE EL CÓDIGO QUE HEMOS SACADO DEL XML
this.player.loadVideoById("xhcqml");
//trace(textofinal);
}
public function onPlayerError(event:Event):void {
// Event.data contains the event parameter, which is the error code
trace("player error:", Object(event).data);
}
public function onPlayerStateChange(event:Event):void {
// Event.data contains the event parameter, which is the new player state
trace("player state:", Object(event).data);
}
}
}Llevo ya un tiempo atascado aqui y no le encuentro solución, por favor una ayuditaa...mis conocimientos de AS3 son limitados. Gracias
