PDA

View Full Version : How can i get the current song of a streaming?


Xavieret
4th May 2007, 01:08
Hi everybody.

I'm a spanish developer, sorry I know that my english isn't good, and I have a little problem with a live radio web.

I have a web page where i have embed windows media. This object read a stream audio from http://s1.viastreaming.net:8000. The code is this one:

<OBJECT ID="MediaPlayer" ...embed media code... </OBJECT>

I want to know how i can to get the current song. I try two solutions but, anyone run well. I don't know if the problem is mine.

The first solution is with a javascript function I try to get the info, but it don't run. This is the code:

function GetMedia()
{
var Media = document.getElementById("MediaPlayer").currentMedia;
// Test whether we have a valid Media object.
if(!Media)
{
divMetadata.innerHTML = "No current media.";
return;
}

// Retrieve the metadata we want to display.
var Title = Media.getItemInfo("Title");
var Artist = Media.getItemInfo("WM/AlbumArtist");
var AlbumTitle = Media.getItemInfo("WM/AlbumTitle");
var Duration = Media.durationString;

// Test the duration string value.
// Streaming media always returns zero.
if(Duration == "00:00")
{
Duration = "No duration available";
}

// Display the metadata in the DIV element.
divMetadata.innerHTML = "Title: " + Title + "<BR>";
divMetadata.innerHTML += "Artist: " + Artist + "<BR>";
divMetadata.innerHTML += "Album: " + AlbumTitle + "<BR>";
divMetadata.innerHTML += "Duration: " + Duration + "<BR>";
}

I call it when i push a button, but this solution doesn't work.

The other solution is this one, but I think that the problem is that the Administrator page of Shoutcast is protected. This code is in C# for an asp.net page:

protected string ObtenerWeb()
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://s1.viastreaming.net:8000");
// Lanzamos la peticion web
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

// Leemos los datos y los metemos en un string
Stream resStream = response.GetResponseStream();
StreamReader StreamRead = new StreamReader(resStream);
string Contenido = StreamRead.ReadToEnd().ToString();

return Contenido;
}

But this solution doesn't work too.

Please, Do you know how can I get info about the current song that's it's playing?

Moved from Winamp Tech Support to SHOUTcast Discussion

NJK
4th May 2007, 17:13
WMP
windows media player can't show the current song when it's used as an embedded player.
the player itself isn't capable of doing this.
you need a now playing script.

sorry, complaints can be send to Bill Gates.:)