How to include html page in "PLAY NOW"-screen - 2008/09/17 06:09Hi all,
I’m a bit experimenting with the “PLAY NOW”-screen and I want to include a frame with a html-page within. In “image_screens.php” I added the following code:
---------------------------------------------------------------------------
SwissCenter SVN 1087
Simese 1.40 / PHP 4.4.4 / MySQL 4.0.21 / Windows XP
Apache 2.2.8 / PHP 5.2.6 / MySQL 5.0.51b / Linux Synology 2.6.15
Synology DS107+ (128), firmware: DSM 2.0-0702
Pinnacle SC200
| | The administrator has disabled public write access.
Pernod
Admin
Posts: 1335
Re: How to include html page in "PLAY NOW"-screen - 2008/09/17 06:25I see what you are trying to do but it will not work.
You have to understand the purpose of image_screens.php, it generates png images, and not html pages.
The Now Playing screen is a png image which is generated and synced which music in a playlist.
When streaming music we are not in browser mode so cannot display html, only sync images.
Does this clarify things?
NigelPlayer : Netgear EVA700 & Popcorn A-100 (081106) Server : Vista SP1 Home Premium (Simese 2.07, SwissCenter current SVN) Spec : Intel C2Q Q6600, 2GB RAM, 1Tb storage.
| | The administrator has disabled public write access.
klaasvaak
User
Posts: 464
Re: How to include html page in "PLAY NOW"-screen - 2008/09/17 07:12Hi Nigel,
Thanks for your swift reply. Yep, I got your point, but I was thinking/hoping that it would be possible to overlay a frame, more or less alike the AlbumArt that is overlaid; too bad.
Is there another way to get the info located the html-file into the “PLAY NOW” screen? IOW is it possible to retrieve the info with a PHP-script?
regards, Klaas --------------------------------------------------------------------------- SwissCenter SVN 1087 Simese 1.40 / PHP 4.4.4 / MySQL 4.0.21 / Windows XP Apache 2.2.8 / PHP 5.2.6 / MySQL 5.0.51b / Linux Synology 2.6.15 Synology DS107+ (128), firmware: DSM 2.0-0702 Pinnacle SC200
| | The administrator has disabled public write access.
Pernod
Admin
Posts: 1335
Re: How to include html page in "PLAY NOW"-screen - 2008/09/17 07:19You can parse the returned html page and use the details to generate the image.
Currently the radio playing screen is static so this would also need changing so that it refreshed at a predefined interval, ie. every 30s.Player : Netgear EVA700 & Popcorn A-100 (081106) Server : Vista SP1 Home Premium (Simese 2.07, SwissCenter current SVN) Spec : Intel C2Q Q6600, 2GB RAM, 1Tb storage.
| | The administrator has disabled public write access.
klaasvaak
User
Posts: 464
Re: How to include html page in "PLAY NOW"-screen - 2008/09/17 08:55Hi Nigel,
but you don't want this in a separate file in the parsers folder. You are also simply echoing the html contents when you should be parsing the contents to get the required data.
In your image_screens.php you also have $track_977_80s["TITLE"] which is never defined.
In image_screens.php try something like this:
// Get html page contents $html = file_get_contents('http://www.977music.com/channels/80s/current.html');
// Get title from html page $title = substr_between_strings($html,'color="#FFFFFFF">','</center>');
You should be applying these changes to music_radio_image.php and not image_screens.php. In music_radio_image.php you can see the refresh period of the radio playing screen is set to 3600secs. Modify this to something more suitable like 30.Player : Netgear EVA700 & Popcorn A-100 (081106) Server : Vista SP1 Home Premium (Simese 2.07, SwissCenter current SVN) Spec : Intel C2Q Q6600, 2GB RAM, 1Tb storage.
| | The administrator has disabled public write access.
klaasvaak
User
Posts: 464
Re: How to include html page in "PLAY NOW"-screen - 2008/09/17 10:27I'm afraid I'm missing the clue. I followed your advice (or at least I think I did) and restored file "/base/image_screens.php" to its orginal state and adjusted file "music_radio_image.php" as follows
Code:
:<?php
/**************************************************************************************************
SWISScenter Source Robert Taylor
*************************************************************************************************/
require_once( realpath(dirname(__FILE__).'/base/image_screens.php'));
require_once( realpath(dirname(__FILE__).'/base/capabilities.php'));
if ( isset($_REQUEST["list"]))
{
// List of images to display to the user (changes every 30 seconds)
$server = server_address();
$url = $server."music_radio_image.php?".current_session()."&station=".urlencode(un_magic_quote($_REQUEST["station"]))."&x=.jpg";
$transition = now_playing_transition();
// Get html page contents
$html = file_get_contents('http://www.977music.com/channels/80s/current.html');
// Get title from html page
$title = substr_between_strings($html,'color="#FFFFFFF">','</center>');
echo "30|$transition| |$url|\n";
echo "30|$transition| |$url|\n";
}
else
{
// Generate and display the "Now Playing" screen.
$image = station_playing_image(un_magic_quote($_REQUEST["station"]));
$image->output('jpeg');
}
/**************************************************************************************************
End of file
**************************************************************************************************/
?>
The original radio screen returns, but no info from the 977 html file.
Can you give me an extra hint, how to deal with this?
many thanks in advance & regards, Klaas ---------------------------------------------------------------------------
SwissCenter SVN 1087
Simese 1.40 / PHP 4.4.4 / MySQL 4.0.21 / Windows XP
Apache 2.2.8 / PHP 5.2.6 / MySQL 5.0.51b / Linux Synology 2.6.15
Synology DS107+ (128), firmware: DSM 2.0-0702
Pinnacle SC200
| | The administrator has disabled public write access.
admin
Admin
Posts: 1542
Re: How to include html page in "PLAY NOW"-screen - 2008/09/17 10:43You would just need to paint the text onto the image:
Adjusting the X,Y location (100,100) as required. Player : Pinnacle Showcenter 200 and 1000 (wired ethernet) Server : Windows XP Pro running on an Athlon XP 2200, 768 Mb RAM, 1.8 Tb storage.
| | The administrator has disabled public write access.
klaasvaak
User
Posts: 464
Re: How to include html page in "PLAY NOW"-screen - 2008/09/17 11:01Hi Rob & Nigel
I'm getting to feel a bit dum by now
Still don't get it to work. I included Rob's suggestion into file "/music_radio_image.php", but the info doesn't appear. Currently, the file looks like this:
Code:
<?php
/**************************************************************************************************
SWISScenter Source Robert Taylor
*************************************************************************************************/
require_once( realpath(dirname(__FILE__).'/base/image_screens.php'));
require_once( realpath(dirname(__FILE__).'/base/capabilities.php'));
if ( isset($_REQUEST["list"]))
{
// List of images to display to the user (changes every 30 seconds)
$server = server_address();
$url = $server."music_radio_image.php?".current_session()."&station=".urlencode(un_magic_quote($_REQUEST["station"]))."&x=.jpg";
$transition = now_playing_transition();
// Get html page contents
$html = file_get_contents('http://www.977music.com/channels/80s/current.html');
// Get title from html page
$title = substr_between_strings($html,'color="#FFFFFFF">','</center>');
echo "30|$transition| |$url|\n";
echo "30|$transition| |$url|\n";
$colour = $this->allocate_colour(255,0,0,0); // (red,green,blue,alpha)
$font_size = 14;
// Generate and display the "Now Playing" screen.
$image = station_playing_image(un_magic_quote($_REQUEST["station"]));
$image->text($title, 100, 100, $colour, $font_size);
$image->output('jpeg');
}
else
{
// Generate and display the "Now Playing" screen.
$image = station_playing_image(un_magic_quote($_REQUEST["station"]));
$image->output('jpeg');
}
/**************************************************************************************************
End of file
**************************************************************************************************/
?>
What should I do?
regards, Klaas ---------------------------------------------------------------------------
SwissCenter SVN 1087
Simese 1.40 / PHP 4.4.4 / MySQL 4.0.21 / Windows XP
Apache 2.2.8 / PHP 5.2.6 / MySQL 5.0.51b / Linux Synology 2.6.15
Synology DS107+ (128), firmware: DSM 2.0-0702
Pinnacle SC200
| | The administrator has disabled public write access.
admin
Admin
Posts: 1542
Re: How to include html page in "PLAY NOW"-screen - 2008/09/17 11:11You put the code in the wrong place, that's all.
The first part of the IF statement returns the list of images that the player will display while the music is playing.
The second part of the IF statement gets used when it's time to actually display the image on the screen. It's here that we need to determine what is playing and paint the text onto the image.
Code:
<?php
/**************************************************************************************************
SWISScenter Source Robert Taylor
*************************************************************************************************/
require_once( realpath(dirname(__FILE__).'/base/image_screens.php'));
require_once( realpath(dirname(__FILE__).'/base/capabilities.php'));
if ( isset($_REQUEST["list"]))
{
// List of images to display to the user (changes every 30 seconds)
$server = server_address();
$url = $server."music_radio_image.php?".current_session()."&station=".urlencode(un_magic_quote($_REQUEST["station"]))."&x=.jpg";
$transition = now_playing_transition();
echo "30|$transition| |$url|\n";
echo "30|$transition| |$url|\n";
}
else
{
// Get html page contents
$html = file_get_contents('http://www.977music.com/channels/80s/current.html');
// Get title from html page
$title = substr_between_strings($html,'color="#FFFFFFF">','</center>');
// Generate and display the "Now Playing" screen.
$image = station_playing_image(un_magic_quote($_REQUEST["station"]));
$colour = $image->allocate_colour(255,0,0,0); // (red,green,blue,alpha)
$font_size = 14;
$image->text($title, 100, 100, $colour, $font_size);
$image->output('jpeg');
}
/**************************************************************************************************
End of file
**************************************************************************************************/
?>
[EDIT] Corrected the setting of $colour. Player : Pinnacle Showcenter 200 and 1000 (wired ethernet) Server : Windows XP Pro running on an Athlon XP 2200, 768 Mb RAM, 1.8 Tb storage.
| | The administrator has disabled public write access.
Pernod
Admin
Posts: 1335
Re: How to include html page in "PLAY NOW"-screen - 2008/09/17 11:14So close...
Code:
<?php
/**************************************************************************************************
SWISScenter Source Robert Taylor
*************************************************************************************************/
require_once( realpath(dirname(__FILE__).'/base/image_screens.php'));
require_once( realpath(dirname(__FILE__).'/base/capabilities.php'));
if ( isset($_REQUEST["list"]))
{
// List of images to display to the user (changes every 30 seconds)
$server = server_address();
$url = $server."music_radio_image.php?".current_session()."&station=".urlencode(un_magic_quote($_REQUEST["station"]))."&x=.jpg";
$transition = now_playing_transition();
echo "30|$transition| |$url|\n";
echo "30|$transition| |$url|\n";
}
else
{
// Generate and display the "Now Playing" screen.
$image = station_playing_image(un_magic_quote($_REQUEST["station"]));
// Get html page contents
$html = file_get_contents('http://www.977music.com/channels/80s/current.html');
// Get title from html page
$title = substr_between_strings($html,'color="#FFFFFFF">','</center>');
$colour = $image->allocate_colour(255,0,0,0); // (red,green,blue,alpha)
$font_size = 14;
$image->text($title, 100, 100, $colour, $font_size);
$image->output('jpeg');
}
/**************************************************************************************************
End of file
**************************************************************************************************/
?>
Player : Netgear EVA700 & Popcorn A-100 (081106) Server : Vista SP1 Home Premium (Simese 2.07, SwissCenter current SVN) Spec : Intel C2Q Q6600, 2GB RAM, 1Tb storage.
| | The administrator has disabled public write access.
klaasvaak
User
Posts: 464
Re: How to include html page in "PLAY NOW"-screen - 2008/09/17 11:40CHAPEAU guys,
You got it to work ...
I'll work it out a bit for all .977 channels and create a "PLAY NOW"-screen. When done I'll post the files for those interested.
once again many thanks for your support, Klaas --------------------------------------------------------------------------- SwissCenter SVN 1087 Simese 1.40 / PHP 4.4.4 / MySQL 4.0.21 / Windows XP Apache 2.2.8 / PHP 5.2.6 / MySQL 5.0.51b / Linux Synology 2.6.15 Synology DS107+ (128), firmware: DSM 2.0-0702 Pinnacle SC200
| | The administrator has disabled public write access.
klaasvaak
User
Posts: 464
Re: How to include html page in "PLAY NOW"-screen - 2008/09/17 12:27Well, I'm back again ... this time for a small issue (I hope).
I cannot change the colour of the displayed info. It's black and whatever colour code I try the characters remain black.
What should I do to get the characters in white?
many thanks and regards, Klaas --------------------------------------------------------------------------- SwissCenter SVN 1087 Simese 1.40 / PHP 4.4.4 / MySQL 4.0.21 / Windows XP Apache 2.2.8 / PHP 5.2.6 / MySQL 5.0.51b / Linux Synology 2.6.15 Synology DS107+ (128), firmware: DSM 2.0-0702 Pinnacle SC200
| | The administrator has disabled public write access.
Pernod
Admin
Posts: 1335
Re: How to include html page in "PLAY NOW"-screen - 2008/09/17 12:45Change the RGB values in the $colour line:
$colour = $image->allocate_colour(255,255,255,0);
Try this site to determine RGB values for various colours.Player : Netgear EVA700 & Popcorn A-100 (081106) Server : Vista SP1 Home Premium (Simese 2.07, SwissCenter current SVN) Spec : Intel C2Q Q6600, 2GB RAM, 1Tb storage.
| | The administrator has disabled public write access.
klaasvaak
User
Posts: 464
Re: How to include html page in "PLAY NOW"-screen - 2008/09/17 13:20Hi Nigel,
Thanks, problem solved, regards, Klaas --------------------------------------------------------------------------- SwissCenter SVN 1087 Simese 1.40 / PHP 4.4.4 / MySQL 4.0.21 / Windows XP Apache 2.2.8 / PHP 5.2.6 / MySQL 5.0.51b / Linux Synology 2.6.15 Synology DS107+ (128), firmware: DSM 2.0-0702 Pinnacle SC200
| | The administrator has disabled public write access.
klaasvaak
User
Posts: 464
Re: How to include html page in "PLAY NOW"-screen - 2008/09/17 16:22Hi Nigel & Rob,
As the journey continues new challenges pop up. With the parser working for the “.977 The 80s Channel” (http://www.977music.com/channels/80s/current.html), the info of this particular station appears on all radio screens, so while listening to “.977 The Classic Rock Channel” (track info stored in (http://www.977music.com/channels/classicrock/current.html), the track details of "The 80s Channel" appear.
In order to avoid this I tried an “if ... else” statement based on $station_name, defined in “/base/image_screens.php”-file, but $station_name isn’t part of “/music_radio_image.php”-file, so the trick doesn’t work.
I suppose the “if … else”-statement should be based upon the url in which the track info is included, but I don’t have a clue how to do this.
Could you help me out once again?
thanks & regards, Klaas --------------------------------------------------------------------------- SwissCenter SVN 1087 Simese 1.40 / PHP 4.4.4 / MySQL 4.0.21 / Windows XP Apache 2.2.8 / PHP 5.2.6 / MySQL 5.0.51b / Linux Synology 2.6.15 Synology DS107+ (128), firmware: DSM 2.0-0702 Pinnacle SC200
| | The administrator has disabled public write access.
Pernod
Admin
Posts: 1335
Re: How to include html page in "PLAY NOW"-screen - 2008/09/17 17:53in music_radio_image.php you can check the station name in $_REQUEST["station"].
Code:
$station_name = un_magic_quote($_REQUEST["station"];
if ($station_name== '.977 The 80s Channel')
$html = file_get_contents('http://www.977music.com/channels/80s/current.html');
elseif ($station_name== '.977 The Classic Rock Channel')
$html = file_get_contents('http://www.977music.com/channels/classicrock/current.html');
else
$html = '';
Player : Netgear EVA700 & Popcorn A-100 (081106) Server : Vista SP1 Home Premium (Simese 2.07, SwissCenter current SVN) Spec : Intel C2Q Q6600, 2GB RAM, 1Tb storage.
| | The administrator has disabled public write access.
klaasvaak
User
Posts: 464
Re: How to include html page in "PLAY NOW"-screen - 2008/09/17 19:05Hi Nigel,
Something's going wron'; I added your suggested code to "/music_radio_image.php" as follows:
Code:
<?php
/**************************************************************************************************
SWISScenter Source Robert Taylor
*************************************************************************************************/
require_once( realpath(dirname(__FILE__).'/base/image_screens.php'));
require_once( realpath(dirname(__FILE__).'/base/capabilities.php'));
if ( isset($_REQUEST["list"]))
{
// List of images to display to the user (changes every 30 seconds)
$server = server_address();
$url = $server."music_radio_image.php?".current_session()."&station=".urlencode(un_magic_quote($_REQUEST["station"]))."&x=.jpg";
$transition = now_playing_transition();
echo "10|$transition| |$url|\n";
echo "10|$transition| |$url|\n";
}
else
{
// Generate and display the "Now Playing" screen & Get html page contents
$station_name = un_magic_quote($_REQUEST["station"];
if ($station_name == '.977 The 80s Channel')
{$html = file_get_contents('http://www.977music.com/channels/80s/current.html');}
elseif ($station_name == '.977 The Classic Rock Channel')
{$html = file_get_contents('http://www.977music.com/channels/classicrock/current.html');}
else
{$html = '';}
// Get title from html page
$title = substr_between_strings($html,'color="#FFFFFFF">','</center>');
$font_size = 14;
$colour_track = $image->allocate_colour(255,255,0);
$image->text(str('TRACK_NAME'), 52, 470, $colour_track, $font_size);
$colour = $image->allocate_colour(255,255,255,0);
$image->text($title, 52, 500, $colour, $font_size);
$image->output('jpeg');
}
/**************************************************************************************************
End of file
**************************************************************************************************/
?>
However, the screen turns black. I've added braces in your "if ... elseif ... else"-statement, but with or without braces still no screen.
Any idea what can I try?
regards, Klaas ---------------------------------------------------------------------------
SwissCenter SVN 1087
Simese 1.40 / PHP 4.4.4 / MySQL 4.0.21 / Windows XP
Apache 2.2.8 / PHP 5.2.6 / MySQL 5.0.51b / Linux Synology 2.6.15
Synology DS107+ (128), firmware: DSM 2.0-0702
Pinnacle SC200
| | The administrator has disabled public write access.
Pernod
Admin
Posts: 1335
Re: How to include html page in "PLAY NOW"-screen - 2008/09/17 20:24Missing bracket at end of $station_name line:
You should get yourself a PHP editor which will show any syntax issues.Player : Netgear EVA700 & Popcorn A-100 (081106) Server : Vista SP1 Home Premium (Simese 2.07, SwissCenter current SVN) Spec : Intel C2Q Q6600, 2GB RAM, 1Tb storage.
| | The administrator has disabled public write access.
klaasvaak
User
Posts: 464
Re: How to include html page in "PLAY NOW"-screen - 2008/09/18 05:26Hi Nigel,
Euh … to be honest I’m using a PHP editor (“PHP Editor 2.22), but you’re right syntax error problems can be easily solved; I’m now using a simple internet tool that flags them.
I worked out the “music_radio_image.php”-file according your suggestion and it seems to work fine by now.
Code:
<?php
/**************************************************************************************************
SWISScenter Source Robert Taylor
*************************************************************************************************/
require_once( realpath(dirname(__FILE__).'/base/image_screens.php'));
require_once( realpath(dirname(__FILE__).'/base/capabilities.php'));
if ( isset($_REQUEST["list"]))
{
// List of images to display to the user (changes every 30 seconds)
$server = server_address();
$url = $server."music_radio_image.php?".current_session()."&station=".urlencode(un_magic_quote($_REQUEST["station"]))."&x=.jpg";
$transition = now_playing_transition();
echo "10|$transition| |$url|\n";
echo "10|$transition| |$url|\n";
}
else
{
// Generate and display the "Now Playing" screen.
$image = station_playing_image(un_magic_quote($_REQUEST["station"]));
// Get html page contents
$station_name = un_magic_quote($_REQUEST["station"]);
if ($station_name == '.977 The 80s Channel')
{$html = file_get_contents('http://www.977music.com/channels/80s/current.html');}
elseif ($station_name == '.977 The Classic Rock Channel')
{$html = file_get_contents('http://www.977music.com/channels/classicrock/current.html');}
else
{$html = '';}
{
// Get title from html page
$title = substr_between_strings($html,'color="#FFFFFFF">','</center>');
$font_size = 14;
if (!empty($html))
{
$colour_track = $image->allocate_colour(255,255,0);
$image->text(str('TRACK_NAME'), 52, 470, $colour_track, $font_size);
}
else
{}
$colour = $image->allocate_colour(255,255,255,0);
$image->text($title, 52, 500, $colour, $font_size);
$image->output('jpeg');
}
}
/**************************************************************************************************
End of file
**************************************************************************************************/
?>
When I’ve got the ‘PLAY NOW”-screen ready for all .977 radio channels and maybe a couple of radio stations more, I’ll post the files.
many thanks to you and Rob for all support to help me out with this,
regards, Klaas ---------------------------------------------------------------------------
SwissCenter SVN 1087
Simese 1.40 / PHP 4.4.4 / MySQL 4.0.21 / Windows XP
Apache 2.2.8 / PHP 5.2.6 / MySQL 5.0.51b / Linux Synology 2.6.15
Synology DS107+ (128), firmware: DSM 2.0-0702
Pinnacle SC200