We are in the process of migrating the Spacial Wiki content to our new Help Center at spacial.com.
Please visit the Help Center for latest Tips and Tricks, Documentation and Troubleshooting.
spacial.com/help-center

Change Stream Title

From SpacialAudio

Jump to: navigation, search

Return to Write Some PAL


There are at least a couple reasons to want to change the title information that is sent in the encoder for title streaming.

  • Your relaying a stream url in SAM
  • You want to stream some text every now and then that identifies the station or a scrolling ad or some other text.



This first example changes title displayed in listener's streaming player.

{ ABOUT:
    Script to change title displayed in listener's streaming player.
    This script will read a banner text source file to get a list of
    messages to display, then switch between the normal song information
    and the banner text on regular intervals.
    
    Not only does this make for a more interesting experience for listeners,
    it also prevents stream rippers from being able to make copies of your
    tracks.
    
  USAGE:
    a) Create a normal plain text file and type your banner messages into this file.
       Each new line should contain one new banner message.
    b) Change the configuration settings below to point to your file and
       specify the interval to wait between changes.
}
    
{ CONFIGURATION }
{==================================================}
const bannertext_file = 'C:\Program Files\SpacialAudio\SAMBC\PAL\BannerText.txt';
const change_interval = '+00:00:15';
{==================================================}


{ IMPLEMENTATION }
{--------------------------------------------------}
var CurSong : TSongInfo;
var UpdSong : TSongInfo;
var Banners : TStringList;
var Toggle  : Boolean = True;
var LinePos : Integer = 0;

{Set this script to restart itself}
PAL.Loop := True;

{ Create some objects that we will need}
UpdSong := TSongInfo.Create;
Banners := TStringList.Create;

{ Load banner lines into stringlist object }
if FileExists(bannertext_file) then
 Banners.LoadFromFile(bannertext_file)
else
 WriteLn('Banner source file does not exist!');
 
LinePos := 0;
while (LinePos<Banners.Count) do
begin
  {Wait for specified time}
  PAL.WaitForTime(change_interval);
  
  {Retrieve the current banner line and assign it to song object}
  UpdSong['title'] := Banners[LinePos];
  
  {Tell encoders to update song information:
    When Toggle is True, we use the normal song information from
    the active player - otherwise we use our banner song object
  }
  Toggle := not Toggle;
  if Toggle then
   begin
    CurSong := ActivePlayer.GetSongInfo;
     Encoders.SongChange(CurSong);
    CurSong.Free;
   end
  else
    Encoders.SongChange(UpdSong);

  {Move to the next line in the banner file before we continue}
  LinePos := LinePos + 1;
end;

{Destroy objects once we no longer need them}
Banners.Free;
UpdSong.Free;
{--------------------------------------------------}

This Script updates the title in the encoder.
Useful if you are Relaying a ShoutCast stream through SAM.

// Set time to stop as 2 hours from now
var timeToStop : DateTime = T['+02:59:00'];

while (now <= timeToStop) do
  begin


{ PAL Script created on 4/10/2006 1:50:23 PM }
{==================================================}
WriteLn('Lets make this puppy run all the time');
{ You will need to edit the next line to point to the URL you are pulling from.}
var html : String = WebToStr('http://pillar-tunez.com:8000/7.html');
var head : String = 
var tail : String = '</body></html>';
WriteLn(html);
////
Delete(html, Pos(head, html), Length(head));
WriteLn(html);

Delete(html, Pos(tail, html), Length(tail));
WriteLn(html);

var i : Integer = 0;
var j : Integer = 0;
while j < 6 do
begin
i := i + 1;
if (CharAt(html, i) = ',') then
begin
j := j + 1;
end;
end;
//
Delete(html, 1, i);
WriteLn(html);

var sepa : String = ' - ';
var artist : String = html;
var title : String = html;

Delete(artist, Pos(sepa, artist), Length(artist));
Delete(title, 1, Pos(sepa, title) + Length(sepa) - 1);

WriteLn(artist);
WriteLn(title);

var Song : TSongInfo;
Song := TSongInfo.Create;
Song['artist'] := artist;
Song['title'] := title;
Encoders.SongChange(Song);
Song.Free;
WriteLn('Waiting 10 Seconds so we are not constantly updating.');
PAL.WaitForTime(T['+00:00:10']); //Wait 5 secs

end;

Personal tools