Moderator: moderators
BrianDelShasta wrote:bytethdgroove, would you mind sharing you code with me as well? Have you figured out how to only display now playing information for a specific account?
Thanks
<?php
//Subsonic Account Information
$user = "xxxxxxxx";
$pass = "xxxxxxxx";
//Path to your Subsonic
$server = "http://xxx.subsonic.org";
//Path to your signature image
$signaturepath = "images/signature1.jpg";
$img = @imagecreatefromjpeg($signaturepath);
//Font settings
$size = 5;
$size2 = 5;
$x = 5; //X Position
$y2 = 0; //Y Position
$y3 = 13;
$y = 86; //Y Position
$x1 = 5; //X Position
$y1 = 100; //Y Position
$color = imagecolorallocate($img,255,255,255);
$yel = imagecolorallocate($img,255,255,0);
$text = "Byte's Subsonic Server";
$text2 = date('D, F d, Y h:i:sa');
$text3 = date('h:i:sa');
$font = 'C:\WINDOWS\Fonts\tf2build.ttf';
$font1 = 'C:\WINDOWS\Fonts\tf2professor.ttf';
$font2 = 'C:\WINDOWS\Fonts\TF2.ttf';
$white = imagecolorallocate($img, 255, 255, 255);
$grey = imagecolorallocate($img, 128, 128, 128);
$black = imagecolorallocate($img, 0, 0, 0);
$red = imagecolorallocate($img, 255, 0, 0);
//Retrieve the XML output from REST
$xmlstr = simplexml_load_file("$server/rest/getNowPlaying.view?u=$user&p=$pass&v=1.3.0&c=forumsig");
//Retrieve Now Playing Information
$artist = $xmlstr->nowPlaying->entry[artist];
$title = $xmlstr->nowPlaying->entry[title];
$album = $xmlstr->nowPlaying->entry[album];
$genre = $xmlstr->nowPlaying->entry[genre];
$year = $xmlstr->nowPlaying->entry[year];
$bitrate = $xmlstr->nowPlaying->entry[bitRate];
$minutesago = $xmlstr->nowPlaying->entry[minutesAgo];
$playername = $xmlstr->nowPlaying->entry[playerName];
//Change header to jpeg, so browsers know that this is an image
header('Content-Type: image/jpeg');
if ($artist && $title) //Check if a song is playing or not, if not, don't write anything!
{
imagettftext($img, 18, 0, 170, 73, $white, $font, $text);
imagettftext($img, 18, 0, 169, 72, $red, $font, $text);
//imagestring($img, $size2,$x,$y2, "Byte's Subsonic Server",$color1);
imagettftext($img, 13, 0, 4, 95, $grey, $font2, "$artist - $album - $title");
imagettftext($img, 13, 0, 3, 94, $white, $font2, "$artist - $album - $title");
//imagestring($img, $size,$x,$y, "$artist-$album-$title",$color);
imagettftext($img, 27, 0, 4, 118, $grey, $font1, "$genre - $year ($minutesago min. ago) on $playername");
imagettftext($img, 27, 0, 3, 117, $white, $font1, "$genre - $year ($minutesago min. ago) on $playername");
//imagestring($img, $size,$x1,$y1, "$genre - $year ($minutesago min. ago) on $playername",$color);
//imagestring($img, $size, $x, $y3, date('D, F-d-Y h:i:sa'), $color);
imagettftext($img, 15, 0, 4, 19, $grey, $font, $text2);
imagettftext($img, 15, 0, 3, 18, $white, $font, $text2);
//imagettftext($img, 15, 0, 4, 45, $grey, $font, $text3);
//imagettftext($img, 15, 0, 3, 44, $yel, $font, $text3);
}
else
{
imagettftext($img, 18, 0, 170, 73, $white, $font, $text);
imagettftext($img, 18, 0, 169, 72, $red, $font, $text);
imagettftext($img, 15, 0, 4, 19, $grey, $font, $text2);
imagettftext($img, 15, 0, 3, 18, $white, $font, $text2);
imagettftext($img, 20, 0, 4, 118, $grey, $font2, "I'm Currently Not Listening To Anything");
imagettftext($img, 20, 0, 3, 117, $white, $font2, "I'm Currently Not Listening To Anything");
//imagestring($img, $size, $x, $y1, "I'm Currently Not Listening To Anything", $color);
//imagestring($img, $size, $x, $y, date('D, F-d-Y h:i:sa'), $color);
//imagestring($img, $size, $x, $y2, "Idle for $minutesago minutes", $color1);
//imagettftext($img, 27, 0, 4, 118, $grey, $font1, date('D, F-d-Y h:i:sa');
//imagettftext($img, 27, 0, 3, 117, $white, $font1, date('D, F-d-Y h:i:sa');
}
imagejpeg($img, 'C:\Inetpub\wwwroot\sig.jpg', 100);
imagejpeg($img);
imagedestroy($img);
?>
Return to Mods, Apps and Clients
Users browsing this forum: No registered users and 6 guests