Ayuda con reproductor flash aac
Tengo un una radio on-line con un reproductor en flash con soporte para aac lo cual me funciona de maravillas, el problema consiste en que a la medianoche apagamos los equipos y la radio web queda en off sin musica y no estoy dipuesto a pagar el presupuesto de un servicio de auto DJ. Entonces se me ocurrio crear una lista de canciones en mp3 las cuales subiria a un FTP para que se reproduzcan solo cuando la radio esta off-line. Tengo muy pocos conocimientos en flash. Este es el codigo con el cual se reproduce la radio en aac:
function initialize()
{
_root.connect.streamStr.text = "http://live1.larastreaming.com:8227";
_root.connect.connectStr.text = "rtmpt://stream.telvi.de:80/shoutcast";
_root.connect.connectButton.onPress = _root.doConnect;
_root.connect.connectButton2.onPress = _root.doConnect;
metaDataValues.title = "";
metaDataValues.genre = "";
metaDataValues.name = "";
metaDataValues.url = "";
doConnect();
trace (System.capabilities.version);
}
function doConnect()
{
if (nc == null)
{
nc = new NetConnection();
nc.onStatus = function (infoObject)
{
trace ("nc: " + infoObject.code + " (" + infoObject.description + ")");
if (infoObject.code == "NetConnection.Connect.Success")
{
playShoutcast();
} // end if
};
nc.connect(_root.connect.connectStr.text);
enablePlayControls(true);
}
else
{
if (nsPlay != null)
{
nsPlay.attachVideo(null);
nsPlay.attachAudio(null);
} // end if
nsPlay = null;
nc.close();
nc = null;
updateMetaData();
enablePlayControls(false);
} // end else if
} // End of the function
function enablePlayControls(isEnable)
{
} // End of the function
function playShoutcast()
{
nsPlay = new NetStream(nc);
nsPlay.onStatus = function (infoObject)
{
trace ("nsPlay: " + infoObject.code + " (" + infoObject.description + ")");
};
nsPlay.onHeaderData = function (infoObject)
{
trace ("onHeaderData");
for (var _loc2 in infoObject)
{
trace (" " + _loc2 + " = " + infoObject[_loc2]);
} // end of for...in
if (infoObject["icy-genre"] != undefined)
{
metaDataValues.genre = infoObject["icy-genre"];
} // end if
if (infoObject["icy-name"] != undefined)
{
metaDataValues.name = infoObject["icy-name"];
} // end if
updateMetaData();
};
nsPlay.onMetaData = function (infoObject)
{
trace ("onMetaData");
for (var _loc2 in infoObject)
{
trace (" " + _loc2 + " = " + infoObject[_loc2]);
} // end of for...in
if (infoObject.StreamTitle != undefined)
{
metaDataValues.title = infoObject.StreamTitle;
} // end if
if (infoObject.StreamUrl != undefined)
{
metaDataValues.url = infoObject.StreamUrl;
} // end if
updateMetaData();
};
nsPlay.setBufferTime(10);
nsPlay.play(_root.connect.streamStr.text);
soundRemote.attachAudio(nsPlay);
} // End of the function
this.mc_vc.show_percent = true;
this.mc_vc.shadow = {distance: 0, angle: 0, color: 0};
var nc = null;
var nsPlay = null;
var metaDataValues = new Array();
Stage.align = "TL";
Stage.scaleMode = "noScale";
_global.style.setStyle("backgroundColor", "0xFFCC00 ");
initialize();
_root.musicPlayer.gotoAndPlay(1);
musicPlays = true;
Y mientas pruebo el reproductor aac en la vista previa si la radio esta on-line aparece la ventana output diciendo lo siguiente:
WIN 10,1,52,14
Nc: NetConnection. Connect. Success (Connection succeeded.)
NsPlay: NetStream. Play.Reset (Playing and resetting http://live1.larastreaming.com:8227.)
NsPlay: NetStream. Play.Start (Started playing http://live1.larastreaming.com:8227.)
OnHeaderData
icy-metaint = 32768
uri = ICY 200 OK
msg = OK
icy-notice2 = SHOUTcast Distributed Network Audio Server/Linux v1.9.8<BR>
icy-name = Orban Opticodec-PC Encoder
icy-pub = 1
icy-genre = Various
status = 200
icy-br = 28
protocol = ICY
content-type = audio/aacp
onMetaData
StreamUrl =
StreamTitle = Hi-Fi Internet Stream
NsPlay: NetStream. Buffer. Full...
function initialize()
{
_root.connect.streamStr.text = "http://live1.larastreaming.com:8227";
_root.connect.connectStr.text = "rtmpt://stream.telvi.de:80/shoutcast";
_root.connect.connectButton.onPress = _root.doConnect;
_root.connect.connectButton2.onPress = _root.doConnect;
metaDataValues.title = "";
metaDataValues.genre = "";
metaDataValues.name = "";
metaDataValues.url = "";
doConnect();
trace (System.capabilities.version);
}
function doConnect()
{
if (nc == null)
{
nc = new NetConnection();
nc.onStatus = function (infoObject)
{
trace ("nc: " + infoObject.code + " (" + infoObject.description + ")");
if (infoObject.code == "NetConnection.Connect.Success")
{
playShoutcast();
} // end if
};
nc.connect(_root.connect.connectStr.text);
enablePlayControls(true);
}
else
{
if (nsPlay != null)
{
nsPlay.attachVideo(null);
nsPlay.attachAudio(null);
} // end if
nsPlay = null;
nc.close();
nc = null;
updateMetaData();
enablePlayControls(false);
} // end else if
} // End of the function
function enablePlayControls(isEnable)
{
} // End of the function
function playShoutcast()
{
nsPlay = new NetStream(nc);
nsPlay.onStatus = function (infoObject)
{
trace ("nsPlay: " + infoObject.code + " (" + infoObject.description + ")");
};
nsPlay.onHeaderData = function (infoObject)
{
trace ("onHeaderData");
for (var _loc2 in infoObject)
{
trace (" " + _loc2 + " = " + infoObject[_loc2]);
} // end of for...in
if (infoObject["icy-genre"] != undefined)
{
metaDataValues.genre = infoObject["icy-genre"];
} // end if
if (infoObject["icy-name"] != undefined)
{
metaDataValues.name = infoObject["icy-name"];
} // end if
updateMetaData();
};
nsPlay.onMetaData = function (infoObject)
{
trace ("onMetaData");
for (var _loc2 in infoObject)
{
trace (" " + _loc2 + " = " + infoObject[_loc2]);
} // end of for...in
if (infoObject.StreamTitle != undefined)
{
metaDataValues.title = infoObject.StreamTitle;
} // end if
if (infoObject.StreamUrl != undefined)
{
metaDataValues.url = infoObject.StreamUrl;
} // end if
updateMetaData();
};
nsPlay.setBufferTime(10);
nsPlay.play(_root.connect.streamStr.text);
soundRemote.attachAudio(nsPlay);
} // End of the function
this.mc_vc.show_percent = true;
this.mc_vc.shadow = {distance: 0, angle: 0, color: 0};
var nc = null;
var nsPlay = null;
var metaDataValues = new Array();
Stage.align = "TL";
Stage.scaleMode = "noScale";
_global.style.setStyle("backgroundColor", "0xFFCC00 ");
initialize();
_root.musicPlayer.gotoAndPlay(1);
musicPlays = true;
Y mientas pruebo el reproductor aac en la vista previa si la radio esta on-line aparece la ventana output diciendo lo siguiente:
WIN 10,1,52,14
Nc: NetConnection. Connect. Success (Connection succeeded.)
NsPlay: NetStream. Play.Reset (Playing and resetting http://live1.larastreaming.com:8227.)
NsPlay: NetStream. Play.Start (Started playing http://live1.larastreaming.com:8227.)
OnHeaderData
icy-metaint = 32768
uri = ICY 200 OK
msg = OK
icy-notice2 = SHOUTcast Distributed Network Audio Server/Linux v1.9.8<BR>
icy-name = Orban Opticodec-PC Encoder
icy-pub = 1
icy-genre = Various
status = 200
icy-br = 28
protocol = ICY
content-type = audio/aacp
onMetaData
StreamUrl =
StreamTitle = Hi-Fi Internet Stream
NsPlay: NetStream. Buffer. Full...
Respuesta de roysoul
1