Skip to Content
It is currently December 4th, 2023, 3:06 pm

All times are UTC - 6 hours [ DST ]




 [ 4 posts ] 
Author Message
 Post subject: SMALL PLAYING SCRIPT
PostPosted: November 22nd, 2020, 5:01 pm 
Offline
Senior User
Senior User

Joined: December 18th, 2004, 1:34 pm
Posts: 166
Location: Hackettstown, New-Jersey U.S.A
Does someone have the script for the: "SMALL PLAYING" (See attached image)?


Attachments:
currently playing.jpg
currently playing.jpg [ 59.87 KiB | Viewed 6669 times ]

_________________
T Kazeem
Nostalgie FM
http://www.nostalgiefm.com
Top
 Profile  
 
 Post subject: Re: SMALL PLAYING SCRIPT
PostPosted: November 24th, 2020, 7:41 am 
Offline
SVS Member
SVS Member

Joined: May 8th, 2004, 9:00 am
Posts: 10572
Location: Denver, CO
To produce this Now playing image requires two steps. This PAL executes the nowplayingimage.php file on your web host, here they are:

nowplayingimage.pal
Replace the XXXXXXXXXXX with your domain.
(!empty($user->lang['CODE'])) ? $user->lang['CODE'] : ucwords(strtolower(str_replace('_', ' ', 'CODE'))):
{ make the pal loop }
PAL.Loop := True;

{ Wait for a track to play }

PAL.WaitForPlayCount(1);
PAL.WaitForTime('+00:00:30');
PAL.LockExecution;
{ Configuration }
{==================================================}
{ Url of the script you are wanting to run }
const theurl = 'https://XXXXXXXXXXX.com/nowplayingimage.php';
{==================================================}
{ End Configuration }

{--------------------------------------------------}

{ Build URL to access the webpage and update stuff }
var URL : String;
URL := ''+theurl+'';

{ execute webpage }
WebToFile('c:\thedummy.txt',URL);
PAL.UnLockExecution;


nowplayingimage.php
(!empty($user->lang['CODE'])) ? $user->lang['CODE'] : ucwords(strtolower(str_replace('_', ' ', 'CODE'))):

<?php

  
// stop hackers from accessing included or required files
  define( "IN_5280Jazz", true );

  // do the setup
  require_once( "include/setup.php" );

  $arr = array("See us at Live365","Tell a friend you heard 5280 Jazz", "Sit back and relax, We deliver!!","Free your mind and the rest will follow, slip into something more comfortable, 5280 Jazz","An oasis for your mind, stress free and relaxing, 5280 Jazz", "Free flowing and easy, 5280 Jazz, your choice for Smooth Jazz on the internet", "We play the music, how you relax to it is up to you", "Streaming Smooth Jazz from the Colorado Rockies", "Uniquely Yours", "For Playlists, Requests and the latest in Smooth Jazz News - you can find us at https://5280jazz.com"); 
  
  srand
((float) microtime() * 1000000); 
  shuffle
($arr); 
  $rand_key 
= array_rand($arr); 
  $theQuote 
= $arr[$rand_key]; 

 
//Get listener count
 $result = mysqli_query( $samDB,  "SELECT sum(viewers) viewers from samrelay" );
 $listenersrow = mysqli_fetch_array( $result );
 $tllisteners = $listenersrow['viewers'];

   // Get what is currently playing 
 $result = mysqli_query( $samDB,  "select * from fhr_now_playing_view" );
 $nowPlayingSong = mysqli_fetch_assoc( $result );
  // Check if song has been requested
 $requestString = "";

    if($nowPlayingSong["requestID"]!=0) {
        $wheresong = $nowPlayingSong['requestID'];
        $result = mysqli_query( $samDB,  "Select userid, username, requestid from requesthistory where requesthistory.requestid = $wheresong");
        $request_id = mysqli_fetch_array( $result );
        if ( $request_id ) {
         if ($request_id['userid'] > 0) {
           $requestString = "~Requested by ".$request_id['username']."~";
            }}
          else
            $requestString 
= "~By Request~"; 
        
}
  if($nowPlayingSong['songtype'] == 'C') 
    $requestString 
= "Merry Christmas From 5280 Jazz";
  
    
//Get todays Featured Artist
  $result = mysqli_query( $samDB, "Select * from songlist s, fhr_featured_artist f where s.fhr_artistid = f.fhr_artistid order by f.date_played desc limit 1");
  $row = mysqli_fetch_assoc( $result );
  $featured = $row['fhr_artistid'];
  if(( $nowPlayingSong['artist_id'] == $featured ) && (date('l') != 'Tuesday'))
    $requestString = "~ Today's Featured Artist ~";
    
  
// Get currently playing show 
  $result = mysqli_query( $samDB, "SELECT text1, text2 FROM currentshow"); 
  $nowPlayingShow 
= mysqli_fetch_array( $result );

// Convert the Rating
  if ($nowPlayingSong["rating"] == 0)
       $songRating = "n/a (no votes)";

// Build the station, show, artist, album, song strings 
  $stationString = "5280 Jazz"; 
  $showString1   
= $nowPlayingShow['text1'];
  $showString2  = $nowPlayingShow['text2']; 
  $artistString 
= "Artist: ".$nowPlayingSong['artist']; 
  $albumString  
= " Album: ".$nowPlayingSong['album']; 
  $songString   
= "  Song: ".$nowPlayingSong['title'];
  $listenerstring = "There are currently ".$tllisteners." listeners tuned in to 5280 Jazz";
  $votes = $nowPlayingSong["votes"];
  if ($nowPlayingSong["votes"] == 0)
    $songRatingstring   = "Rating: ".$songRating;
  else 
    $songRatingstring   
= "Rating: ".$nowPlayingSong["rating"]. " out of 5 by our listeners";

    // Initialize the length 
  $maxStringSize = 0; 
  
// Bubble the longest string length to maxStringSize 
  if (strlen($stationString) > $maxStringSize) 
    $maxStringSize 
= strlen($stationString); 
  if 
(strlen($showString1) > $maxStringSize) 
    $maxStringSize 
= strlen($showString1);
  if (strlen($showString2) > $maxStringSize) 
    $maxStringSize 
= strlen($showString2);  
  if 
(strlen($artistString) > $maxStringSize) 
    $maxStringSize 
= strlen($artistString); 
  if 
(strlen($albumString) > $maxStringSize) 
    $maxStringSize 
= strlen($albumString); 
  if 
(strlen($songString) > $maxStringSize) 
    $maxStringSize 
= strlen($songString); 
  if 
(strlen($theQuote) > $maxStringSize) 
    $maxStringSize 
= strlen($theQuote); 
  if 
(strlen($songRatingstring) > $maxStringSize) 
    $maxStringSize 
= strlen($songRatingstring); 
  if 
(strlen($requestString) > $maxStringSize) 
    $maxStringSize 
= strlen($requestString); 
  if 
(strlen($listenerstring) > $maxStringSize) 
    $maxStringSize 
= strlen($listenerstring); 

 
// Build the album cover path 
  if(empty($nowPlayingSong["picture"])) { 
    $nowPlayingSong
["picture"] = "na.jpg";  // This MUST be a jpg file!!! 
  }  
  $AlbumCoverPath 
= "coverart/". rawurlencode($nowPlayingSong["picture"]);
  $theHeight = 86;
  // Get the size of the album cover image for use in imagecopyresized function later 
  list($coverwidth, $coverheight) = getimagesize($AlbumCoverPath); 
  
  
// Create the album cover image resource -- IMAGE MUST BE A JPG!!! 
  $AlbumCoverImage = imagecreatefromjpeg($AlbumCoverPath); 
  
  
// Define final image width and starting x location for placement of album cover image 
  $imageWidth = 5 * $maxStringSize + 110; 
  $x_start 
= 90; 

    
// Create the image for the now playing text 
  $im  = imagecreatetruecolor ($imageWidth, $theHeight);  // Must create a true color image for use with JPGs. 
  imagesavealpha($im, true); 
  $bgc 
= imagecolorallocatealpha ($im, 0, 0, 0, 127); 
  imagefill
($im, 0, 0, $bgc);  // Used with imagesavealpha, creates a transparent image 

  $tc  = imagecolorallocate ($im, 0, 0, 0);
  $tcw  = imagecolorallocate ($im, 255, 255, 255); 
  $tcr  
= imagecolorallocate ($im, 255, 0, 0);
  $tcg = imagecolorallocate ($im, 0, 128, 0);



  // Place now playing information on image 
  imagestring ($im, 1, $x_start, 0, $stationString, $tc); 
  imagestring 
($im, 1, $x_start, 9, $showString1, $tc); 
  imagestring 
($im, 1, $x_start, 17, $showString2, $tc); 
  imagestring 
($im, 1, $x_start, 24, $listenerstring, $tc);
  imagestring ($im, 1, $x_start, 33, $artistString, $tc); 
  imagestring 
($im, 1, $x_start, 42, $albumString, $tc); 
  imagestring 
($im, 1, $x_start, 51, $songString, $tc); 
  imagestring 
($im, 1, $x_start, 60, $songRatingstring, $tc);
  if($now_playing['songtype'] == 'C') {
  imagestring ($im, 1, $x_start, 68, $requestString, $tcg);
}
 else {
  imagestring ($im, 1, $x_start, 68, $requestString, $tcr); 
}
  
  imagestring 
($im, 1, $x_start, 76, $theQuote, $tc);
  // Copy the album cover onto the now playing text image 
  imagecopyresized($im, $AlbumCoverImage, 2, 2, 0, 0, 80, 80, $coverwidth, $coverheight); 

  
// Output the image
  ImagePNG($im, 'nowplaying_image/5280jazz.png');

  imagestring ($im, 1, $x_start, 0, $stationString, $tcw); 
  imagestring 
($im, 1, $x_start, 9, $showString1, $tcw); 
  imagestring 
($im, 1, $x_start, 17, $showString2, $tcw); 
  imagestring 
($im, 1, $x_start, 24, $listenerstring, $tcw);
  imagestring ($im, 1, $x_start, 33, $artistString, $tcw); 
  imagestring 
($im, 1, $x_start, 42, $albumString, $tcw); 
  imagestring 
($im, 1, $x_start, 51, $songString, $tcw); 
  imagestring 
($im, 1, $x_start, 60, $songRatingstring, $tcw);
  if($nowPlayingSong['songtype'] == 'C') {
  imagestring ($im, 1, $x_start, 68, $requestString, $tcg);
}
 else {
  imagestring ($im, 1, $x_start, 68, $requestString, $tcr); 
}
  
  imagestring 
($im, 1, $x_start, 76, $theQuote, $tcw);

  // Output the white image 
  ImagePNG($im, 'nowplaying_image/5280jazz_w.png'); 
 
 
//output image for forum header (Black background image)
  ImageGIF($im, 'forum/styles/prosilver/imageset/site_logo.gif');

  imagedestroy($im);
  require_once( "include/teardown.php" );
?>

Notes:
PHP nowplayingimage.php script, produces two png files, one with transparent background and one with white background (used for forums with dark backgrounds).
The scripts setup.php & teardown.php are simply files that do the open/close connection strings to the database.
fhr_now_playing_view is an mysql view that retrieves all the currently playing track fields required for the output.

_________________
- Rob Oyler, SVS
Image


Top
 Profile  
 
 Post subject: Re: SMALL PLAYING SCRIPT
PostPosted: July 18th, 2021, 1:48 pm 
Offline
New User
New User

Joined: July 13th, 2021, 11:38 am
Posts: 3
Location: Moyock, NC
I tried this and put in the Sam Pal Script. It went off but not sure were it put the output?

_________________
Tom Barstow
tbarstow@soundmachineradio.com
www.soundmachineradio.com


Top
 Profile  
 
 Post subject: Re: SMALL PLAYING SCRIPT
PostPosted: July 19th, 2021, 7:54 am 
Offline
SVS Member
SVS Member

Joined: May 8th, 2004, 9:00 am
Posts: 10572
Location: Denver, CO
DJBearsmr (!empty($user->lang['WROTE'])) ? $user->lang['WROTE'] : ucwords(strtolower(str_replace('_', ' ', 'WROTE'))):
I tried this and put in the Sam Pal Script. It went off but not sure were it put the output?

Assuming it completed and there were no errors from your edits, it would have created a file on your web host were you changed these two lines of code
(!empty($user->lang['CODE'])) ? $user->lang['CODE'] : ucwords(strtolower(str_replace('_', ' ', 'CODE'))):
 // Output the white image 
  ImagePNG($im, 'nowplaying_image/5280jazz_w.png'); 
 
 
//output image for forum header (Black background image)
  ImageGIF($im, 'forum/styles/prosilver/imageset/site_logo.gif'); 


If you don't have the same database fields for ratings that I do you will definitely have errors in the php execution. The PAL script itself only executes the remote php file. YOu would have to modify the php file to suite your needs if you are running the standard SAM database.

_________________
- Rob Oyler, SVS
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
 [ 4 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 16 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group