tengo un reproductor de videos de youtube que se cargan por medio de un XML y la miniatura se genera automaticamente,el problema es que en dos de los videos no aparece miniatura
aca tengo colgado el reproductor:
Código PHP :
http://pruebita.net84.net/
este es el XML:
Código XML :
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <playlist> <track> <title>Shanghai World Expo 2010 Sights and Sounds</title> <youtube>Ei9udm9sbNw</youtube> <details>(livingradically) - 06/05/2010</details> </track> <track> <title>Expo Shanghai Colombia Pavilion 2010</title> <youtube>welBcx8EQuY&hl</youtube> <details>(juliangimenezagut) - 06/05/2010</details> </track> <track> <title>Shanghai Launches Expo Extravaganza</title> <youtube>aCmN-P-L5OM&hl=es_ES&fs=1&</youtube> <details>(AP) - 30/04/2010</details> </track> <track> <title>Opening ceremony of Expo Shanghai 2010 - Part 1 of 5</title> <youtube>vkyDsr3mMlM</youtube> <details>(CCTV) 30/04/2010</details> </track> <track> <title>Opening ceremony of Expo Shanghai 2010 - Part 2 of 5</title> <youtube>v4rWWaoDCj8</youtube> <details>(CCTV) 30/04/2010</details> </track> <track> <title>Opening ceremony of Expo Shanghai 2010 - Part 3 of 5</title> <youtube>KygfB_rM1fs</youtube> <details>(CCTV) 30/04/2010</details> </track> <track> <title>Opening ceremony of Expo Shanghai 2010 - Part 4 of 5</title> <youtube>rxvTvOFHFsA</youtube> <details>(CCTV) 30/04/2010</details> </track> <track> <title>Opening ceremony of Expo Shanghai 2010 - Part 5 of 5</title> <youtube>reV5WGcH2gk</youtube> <details>(CCTV) 30/04/2010</details> </track> </playlist>
este es el AS:
Código ActionScript :
import mx.transitions.Tween;
import mx.transitions.easing.*;
System.security.allowDomain("youtube.com","http://youtube.com","www.youtube.com","8.7.217.31");
controlButtons.playPause.gotoAndStop("play");
Stage.scaleMode = "noScale";
Stage.align = "TL";
Stage.showMenu = false;
// create a listener object for the MovieClipLoader to use
var ytPlayerLoaderListener:Object = {
onLoadInit: function() {
loadInterval = setInterval(checkPlayerLoaded, 250);
}
};
var loadInterval:Number;
var theVideos:Array = new Array();
var whoIsOn:Number = 0;
var nodes;
var theTitles:Array = new Array();
var theDetails:Array = new Array();
var shuffle:Boolean = false;
var repeat:Boolean = false;
var playInterval:Number;
var firstTimePlayed:Boolean = true;
function startPlay(){
clearInterval(playInterval);
textChange();
ytplayer.loadVideoById(theVideos[whoIsOn], 0);
}
function beforeStartPlay(){
clearInterval(playInterval);
playInterval = setInterval(startPlay, 1000);
theCurrentItem();
ytplayer.pauseVideo();
}
function checkPlayerLoaded():Void {
if (ytplayer.isPlayerLoaded()) {
ytplayer.setSize(456, 340);
ytplayer._x = 10;
ytplayer._y = 10;
ytplayer.addEventListener("onStateChange", onPlayerStateChange);
ytplayer.addEventListener("onError", onPlayerError);
clearInterval(loadInterval);
}
}
function checkPlayerLoaded2():Void {
firstTimePlayed = false;
if (ytplayer.isPlayerLoaded()) {
startPlay();
theCurrentItem();
whoIsOn = 0;
clearInterval(loadInterval2);
}
}
/*onStateChange - This event is fired whenever the player's state changes.
Possible values are unstarted (-1), ended (0), playing (1),
paused (2), buffering (3), video cued (5).
When the SWF is first loaded it will broadcast an unstarted (-1) event.
When the video is cued and ready to play it will broadcast a video cued event (5).*/
function onPlayerStateChange(newState:Number) {
trace("New player state: "+ newState);
if(newState == 2 && controlButtons.playPause._currentframe == 30){
controlButtons.playPause.gotoAndStop("playOver");
}else if(controlButtons.playPause._currentframe == 20){
controlButtons.playPause.gotoAndStop("pause");
}
if(newState == 0){
if(shuffle == false){
if(repeat == false){
whoIsOn++;
if(whoIsOn >= nodes.length){
whoIsOn = 0;
listBox.dragger._y = 0;
}
}
}else{
if(repeat == false){
whoIsOn = Math.floor(Math.random()*(nodes.length-1));
}
}
beforeStartPlay();
}
if(newState == 1){
if(_root.get_highest_quality == "true"){
theQuality();
}
progressBar.onEnterFrame = videoUpdate;
butArray[whoIsOn].theTime.text = getTimecode(ytplayer.getDuration());
}
if(newState == 5){
controlButtons.playPause.gotoAndStop("play");
}
}
function onPlayerError(errorCode:Number) {
//trace("An error occurred: "+ errorCode);
errorItem();
//if(errorCode == 100){
whoIsOn++;
if(whoIsOn >= nodes.length){
whoIsOn = 0;
}
beforeStartPlay();
//}
}
// create a MovieClipLoader to handle the loading of the player
var ytPlayerLoader:MovieClipLoader = new MovieClipLoader();
ytPlayerLoader.addListener(ytPlayerLoaderListener);
// load the player
ytPlayerLoader.loadClip("http://www.youtube.com/apiplayer", ytplayer);
//xml stuff
var myXML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function(){
theVideos = [];
whoIsOn = 0;
nodes = this.firstChild.childNodes;
for(var i=0;i<nodes.length;i++){
theTitles.push(nodes[i].childNodes[0].firstChild.nodeValue);
theVideos.push(nodes[i].childNodes[1].firstChild.nodeValue);
theDetails.push(nodes[i].childNodes[2].firstChild.nodeValue);
}
loadMenu();
if(_root.autoplay != "false"){
loadInterval2 = setInterval(checkPlayerLoaded2, 250);
}
}
if(_root.playlist){
myXML.load(_root.playlist + ".xml");
}else{
myXML.load("vinculos.xml");
}
var listener:Object = new Object();
listener.tmc = target;
listener.onLoadInit = function(mc:MovieClip) {
new Tween(mc,"_alpha", Strong.easeOut,0,100,1,true);
mc._width = 65;
mc._height = 50;
};
var loader:MovieClipLoader = new MovieClipLoader();
loader.addListener(listener);
overlayBtn.useHandCursor = false;
overlayBtn._visible = false;
var btnOver;
var butArray:Array = new Array();
function loadMenu(){
for (var i:Number=0;i<theTitles.length;i++){
var but:MovieClip = listBox.theList.attachMovie("listItem","listItem"+i,i,{_y:(i*60)});
but.theName.htmlText = theTitles[i];
but.theDescription.htmlText = theDetails[i];
loader.loadClip("http://img.youtube.com/vi/" + theVideos[i] + "/2.jpg", but.theThumbnail);
but.i = i;
butArray.push(but)
if((i & 1) == 0){
var my_colorB1:Color = new Color(but.itemBg);
my_colorB1.setRGB(0xF7F7F7);
}else{
var my_colorB1:Color = new Color(but.itemBg);
my_colorB1.setRGB(0xF1F1F1);
}
but.onRollOver = function(){
if(_root.rollover_changing_thumbs == "true"){
btnOver = this;
thumbInterval = setInterval(thumbTimer, 1000);
}
}
but.onRollOut = but.onReleaseOutside = function(){
if(_root.rollover_changing_thumbs == "true"){
clearInterval(thumbInterval);
vTime = 0;
}
}
but.onRelease = function(){
whoIsOn = this.i;
beforeStartPlay();
}
}
}
var vTime:Number = 0;
function thumbTimer(){
vTime++;
switch (vTime) {
case 1 :
//btnOver.theThumbnail.loadMovie("http://img.youtube.com/vi/" + theVideos[btnOver.i] + "/1.jpg");
loader.loadClip("http://img.youtube.com/vi/" + theVideos[btnOver.i] + "/1.jpg", btnOver.theThumbnail);
break;
case 2:
//btnOver.theThumbnail.loadMovie("http://img.youtube.com/vi/" + theVideos[btnOver.i] + "/2.jpg");
loader.loadClip("http://img.youtube.com/vi/" + theVideos[btnOver.i] + "/2.jpg", btnOver.theThumbnail);
break;
case 3:
//btnOver.theThumbnail.loadMovie("http://img.youtube.com/vi/" + theVideos[btnOver.i] + "/3.jpg");
loader.loadClip("http://img.youtube.com/vi/" + theVideos[btnOver.i] + "/3.jpg", btnOver.theThumbnail);
vTime = 0;
break;
}
}
function errorItem(){
var my_colorB4:Color = new Color(butArray[whoIsOn].theName);
my_colorB4.setRGB(0xFF0000);
}
function theCurrentItem(){
if(listBox.theList._height > listBox.theMask._height && listBox.dragger._y <= (listBox.theMask._height - listBox.dragger._height)){
listBox.dragger._y = ((listBox.theMask._height-listBox.dragger._height)/100)*((whoIsOn*100)/(nodes.length-1));
}
var my_colorB2:Color = new Color(butArray[whoIsOn].itemBg);
my_colorB2.setRGB(0xCFE0E9);
butArray[whoIsOn].theName.htmlText = "<b>"+theTitles[whoIsOn]+"</b>";
for (var i:Number=0;i<theTitles.length;i++){
if(i != whoIsOn){
butArray[i].theName.htmlText = theTitles[i];
if((butArray[i].i & 1) == 0){
var my_colorB3:Color = new Color(butArray[i].itemBg);
my_colorB3.setRGB(0xF7F7F7);
}else{
var my_colorB3:Color = new Color(butArray[i].itemBg);
my_colorB3.setRGB(0xF1F1F1);
}
}
}
}
controlButtons.nextBtn.onRelease = function(){
if(shuffle == true){
whoIsOn = Math.floor(Math.random()*(nodes.length-1));
}else{
whoIsOn++;
if(whoIsOn >= nodes.length){
whoIsOn = 0;
}
}
beforeStartPlay();
}
controlButtons.prevBtn.onRelease = function(){
if(shuffle == true){
whoIsOn = Math.floor(Math.random()*(nodes.length-1));
}else{
whoIsOn--;
if(whoIsOn < 0){
whoIsOn = nodes.length-1;
}
}
beforeStartPlay();
}
//play - pause
controlButtons.playPause.onRollOver = function() {
if(this._currentframe == 1) {
controlButtons.playPause.gotoAndStop("pauseOver");
}
else {
controlButtons.playPause.gotoAndStop("playOver");
}
}
controlButtons.playPause.onRollOut = function() {
if(this._currentframe == 10) {
controlButtons.playPause.gotoAndStop("pause");
}
else {
controlButtons.playPause.gotoAndStop("play");
}
}
controlButtons.playPause.onRelease = function() {
if(firstTimePlayed == true){
loadInterval2 = setInterval(checkPlayerLoaded2, 250);
}
if(this._currentframe == 10) {
controlButtons.playPause.gotoAndStop("playOver");
ytplayer.pauseVideo();
}else{
controlButtons.playPause.gotoAndStop("pauseOver");
ytplayer.playVideo();
}
}
shuffleBtn.onRelease = function(){
if(this._currentframe == 1) {
this.gotoAndStop(2);
shuffle = true;
}else{
this.gotoAndStop(1);
shuffle = false;
}
}
repeatBtn.onRelease = function(){
if(this._currentframe == 1) {
this.gotoAndStop(2);
repeat = true;
}else{
this.gotoAndStop(1);
repeat = false;
}
}
//progress
function videoUpdate(){
if (ytplayer.getDuration() > 0) {
progressBar._xscale = (ytplayer.getCurrentTime()/ytplayer.getDuration())*100;
scrub._x = Math.floor(progressBar._width+progressBar._x);
}
else {
scrub._x = progressBar._x;
}
theTime.text = getTimecode(ytplayer.getCurrentTime())+" / "+getTimecode(ytplayer.getDuration());
if(theTime.text == "NaN:NaN / NaN:NaN"){
theTime.text = "00:00 / 00:00";
}
}
loadBar.onPress = function() {
progressBar.onEnterFrame = videoScrub;
}
loadBar.onRelease = loadBar.onReleaseOutside = function() {
delete progressBar.onEnterFrame;
}
function videoScrub() {
var dist:Number = (_xmouse-loadBar._x)/loadBar._width;
if(dist < 0){
dist = 0;
}
if(dist > 1){
dist = 1;
}
ytplayer.seekTo(Math.floor(ytplayer.getDuration()*dist), true);
progressBar._xscale = (dist)*100;
scrub._x = Math.floor(progressBar._width+loadBar._x);
}
scrub._x = loadBar._x;
progressBar._xscale = 0;
//time code
function getTimecode(theTime) {
var t:Number = Math.round(theTime);
var min:Number = Math.floor(t/60);
var sec:Number = t%60;
var s:String = "";
if(min < 10) {
s += "0";
}
if(min >= 1) {
s += min.toString();
}
else {
s += "0";
}
s += ":";
if(sec < 10) {
s += "0";
s += sec.toString();
}
else {
s += sec.toString();
}
return s;
}
closeBtn._visible = false;
bottomLayout._visible = false;
closeBtn.onRelease = function(){
if (Stage["displayState"] != "normal") {
Stage["displayState"] = "normal";
}
normalScreen();
}
bigScreenBtn._visible = false;
//delete the above code line if you want to enter full screen mode when you click on the video screen
bigScreenBtn.onRelease = function(){
toggleFullScreen();
}
//full screen button
fsBtn.onRollOver = function() {
if(this._currentframe == 1) {
this.gotoAndStop("goFsOver");
}
else {
this.gotoAndStop("backToNormalOver");
}
}
fsBtn.onRollOut = function() {
if(this._currentframe == 10) {
this.gotoAndStop("goFs");
}
else {
this.gotoAndStop("backToNormal");
}
}
fsBtn.onRelease = function() {
if(this._currentframe == 10) {
toggleFullScreen();
this.gotoAndStop("backToNormalOver");
}
else {
toggleFullScreen();
this.gotoAndStop("goFsOver");
}
}
function toggleFullScreen(){
if (Stage["displayState"] == "normal") {
Stage["displayState"] = "fullScreen";
fullScreen();
}else{
normalScreen();
Stage["displayState"] = "normal";
}
}
function fullScreen(){
loadBar._x = 106;
loadBar._y = Stage.height - 23;
loadBar.loadBarIn._width = Stage.width - 241;
loadBar.loadBarBg._width = Stage.width - 240;
progressBar._x = loadBar._x + .5;
progressBar._y = loadBar._y + .5;
progressBar.progressBarIn._width = loadBar.loadBarIn._width;
scrub._y = progressBar._y - 4;
controlButtons._x = 10;
controlButtons._y = Stage.height - 37;
overlayBtn._visible = true;
closeBtn._visible = true;
ytplayer._x = 0;
ytplayer._y = 0;
ytplayer.setSize(Stage.width, Stage.height-42);
closeBtn._x = Stage.width-34;
closeBtn._y = Stage.height-30;
fsBtn._x = Stage.width - 64;
fsBtn._y = closeBtn._y;
volumeMc._x = Stage.width-124;
volumeMc._y = Stage.height-28;
}
function normalScreen(){
fsBtn.gotoAndStop("goFs");
loadBar._x = 112;
loadBar._y = 372;
loadBar.loadBarIn._width = 250;
loadBar.loadBarBg._width = 251;
progressBar._x = loadBar._x + .5;
progressBar._y = loadBar._y + .5;
progressBar.progressBarIn._width = loadBar.loadBarIn._width;
scrub._y = loadBar._y - 4;
controlButtons._x = 15;
controlButtons._y = 358;
fsBtn._visible = true;
closeBtn._visible = false;
closeBtn._x = 331;
closeBtn._y = 274;
fsBtn._x = 443;
fsBtn._y = 365;
ytplayer.setSize(456, 340);
ytplayer._x = 10;
ytplayer._y = 10;
bottomLayout._visible = true;
overlayBtn._visible = true;
overlayBtn._width = 362;
overlayBtn._height = 308;
volumeMc._x = 381;
volumeMc._y = 367;
}
normalScreen()
var stageResize:Object = new Object();
stageResize.onResize = function(){
if (Stage["displayState"] == "normal") {
normalScreen();
}
}
Stage.addListener(stageResize);
//volume code
ytplayer.setVolume(dist);
volumeMc.volScrub._xscale = 70;
volumeMc.volBottom.onPress = function() {
adjustSound();
this.onMouseMove = adjustSound;
}
volumeMc.volBottom.onRelease = volumeMc.volBottom.onReleaseOutside = function() {
delete this.onMouseMove;
}
function adjustSound() {
var dist:Number = Math.floor(((volumeMc._xmouse-volumeMc.volBottom._x)/volumeMc.volBottom._width)*100);
if(dist >= 0 && dist <= 100) {
volumeMc.volScrub._xscale = dist;
ytplayer.setVolume(dist);
}
}
function theQuality(){
var qualityLevels:Array = ytplayer.getAvailableQualityLevels();
// qualityLevels may be undefined if the API function does not exist,
// in which case this conditional is false
if (qualityLevels.length > 1) {
var highestQuality:String = qualityLevels[0];
trace(highestQuality)
if (highestQuality == "hd720") {
// Brand quality toggle button as HD.
ytplayer.setPlaybackQuality("hd720");
//trace(ytplayer.getPlaybackQuality())
} else {
// Brand quality toggle button as HQ.
// The highest available quality is shown, but it is not HD video.
ytplayer.setPlaybackQuality("large");
}
var quality:String = getPlaybackQuality();
if (quality == 'small' || quality == 'medium') {
// The user is not watching the highest quality available
// can can toggle to a higher quality.
} else {
// The user is watching the highest quality available
// and can toggle to a lower quality.
}
} else {
// Hide the toggle button because there is no current video or
// there is only one quality available.
}
}
les agradezco su amable ayuda
